1/7
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.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
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.
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.
What is the best case scenario for a linear search?
The target item is at the first position in the list.
What is the worst case scenario for a linear search?
The target item is not in the list at all.
What are the benefits of linear search?
Very easy to implement
Can be applied to any list, whether it is ordered or not.
What are the drawbacks of linear search?
Slow on a long list
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)Describe in words an algorithm for carrying out an algorithm.
If the length of the list is zero, stop.
Start at the beginning of the list.
Compare the list item with the search criterion.
If they are the same, then stop.
If they are not the same, then move to the next item.
Repeat steps 3 to 5 until the end of the list is reached.