Overview
Linear Search scans the input in order and compares each item with the target. It needs no preprocessing and works on unsorted data.
Finds a target by checking items one by one until a match is found or the input ends.
Compact metadata for implementation and discovery.
Linear Search scans the input in order and compares each item with the target. It needs no preprocessing and works on unsorted data.
Quick facts
Runtime and memory behavior at a glance.
Best
O(1)
Average
O(n)
Worst
O(n)
Space
O(1)
Show a cursor checking each item from left to right.
Linear search is often the right choice when simplicity beats preprocessing cost.
What each reference supports for this entry.
Algorithms textbook support for Linear Search's invariant, correctness argument, and asymptotic analysis.
Open sourceGood next jumps from the relationship graph, ranked for useful discovery.
Linear search scans unsorted data, while binary search requires sorted order.
Naive string search applies a direct scan-and-compare strategy over text.