Binary Search vs Exponential Search
Across our 4 test inputs, Binary Search needed 17 comparisons in total versus 25 for Exponential Search. Binary Search is stable; Exponential Search is not.
Head-to-head on identical inputs (comparisons)
| Input | Binary Search | Exponential Search |
|---|---|---|
| Target is first | 4 | 1 |
| Target in the middle | 4 | 7 |
| Target is last | 5 | 9 |
| Target absent | 4 | 8 |
Complexity
| Binary Search | Exponential Search | |
|---|---|---|
| Average time | O(log n) | O(log n) |
| Worst time | O(log n) | O(log n) |
| Space | O(1) | O(1) |
| Stable | Yes | No |
When to use Binary Search
Sorted arrays when O(log n) search time is needed. Foundation for many advanced algorithms.
When to use Exponential Search
Unbounded or very large sorted lists, or when the target is likely near the start.