SearchingAnimated
Linear Search
Check each element in turn until the target is found.
Time
O(n)
Extra space
O(1)
Use it for
Unsorted or tiny lists.
How it works
- Start at the first element.
- Compare it with the target. If equal, stop: found.
- Otherwise move to the next element.
- If you run past the end, the target is not in the list.
- No ordering is needed, but in the worst case every element is checked.
Watch it run
Loading animation…