Linear Search vs Exponential Search
Across our 4 test inputs, Exponential Search needed 25 comparisons in total versus 42 for Linear Search. On average Linear Search runs in O(n) time and Exponential Search in O(log n). Linear Search is stable; Exponential Search is not. Exponential Search only works on sorted data.
Head-to-head on identical inputs (comparisons)
| Input | Linear Search | Exponential Search |
|---|---|---|
| Target is first | 1 | 1 |
| Target in the middle | 9 | 7 |
| Target is last | 16 | 9 |
| Target absent | 16 | 8 |
Complexity
| Linear Search | Exponential Search | |
|---|---|---|
| Average time | O(n) | O(log n) |
| Worst time | O(n) | O(log n) |
| Space | O(1) | O(1) |
| Stable | Yes | No |
When to use Linear Search
Unsorted arrays, small datasets, or when you need to find all occurrences.
When to use Exponential Search
Unbounded or very large sorted lists, or when the target is likely near the start.