ƒ(x) SearchingCore interactive
Linear Search
Check each element until you find the target.
linear_search
step 1 / 15
4
07
19
221
324
429
539
642
743
852
959
1078
1183
12Scan left to right for 83.
cursoreliminatedfound
speed1×
target = 83
How it works
Linear search walks the collection one element at a time. It needs no ordering and works on anything iterable, but it's O(n) — the baseline every faster search is measured against.
Mental models
- The only option on unsorted data.
- No preprocessing required.
Complexity
- Best
- O(1)
- Average
- O(n)
- Worst
- O(n)
- Space
- O(1)