15. Linear Search

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/7

flashcard set

Earn XP

Description and Tags

When large amounts of data are searched, it is essential that the searching algorithm is as efficient as possible. Linear searches are usually slower than binary searches, particularly on long lists.

Last updated 1:26 PM on 7/27/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

8 Terms

1
New cards

What is a linear research?

It is a sequential algorithm, starting at the beginning of the list and moving through item by item until it finds the matching item or reaches the end of the list.

2
New cards

What is a linear search an example of? Is this an efficient method?

A brute force algorithm that does not require any specialist techniques, only raw computing power. It is not an efficient method as each search starts at the beginning and keeps going until the item is found or the end of the list is reached.

3
New cards

What is the best case scenario for a linear search?

The target item is at the first position in the list.

4
New cards

What is the worst case scenario for a linear search?

The target item is not in the list at all.

5
New cards

What are the benefits of linear search?

  • Very easy to implement

  • Can be applied to any list, whether it is ordered or not.

6
New cards

What are the drawbacks of linear search?

  • Slow on a long list

7
New cards

What is the program code for the linear search algorithm?

list = [ ]

target = ""

found = False

for value in list:
    if value == target:
        found = True
print(found)
list = [ ]

target = ""

found = False

index = 0

length = len(list)

while ((not found) and (index < length)):
    if (target == list[index]):
        found = True
    index += 1
print(found)

8
New cards

Describe in words an algorithm for carrying out an algorithm.

  1. If the length of the list is zero, stop.

  2. Start at the beginning of the list.

  3. Compare the list item with the search criterion.

  4. If they are the same, then stop.

  5. If they are not the same, then move to the next item.

  6. Repeat steps 3 to 5 until the end of the list is reached.