Save
...
Searching and sorting algorithms
Searching
Linear search
Save
Share
Learn
Content
Leaderboard
Share
Learn
Created by
Tin
Visit profile
Cards (5)
On what types of lists does linear search work?
It works on both sorted and unsorted lists.
When is linear search most efficient?
It is efficient for
small lists
or when searching
infrequently.
What are the steps of the linear search algorithm?
Start at the
beginning
of the list.
Compare
the
current
element with the
target
value.
If they match,
return
the
current position.
If they don't match,
move
to the
next element.
Repeat
until the element is
found
or the
end
of the list is
reached.
If the end is
reached
without
a match, return "
not found
".
What is a
disadvantage
of using linear search?
It
is
slow for large datasets.
What is the primary advantage of linear search?
It is simple to understand and implement.