Interpolation Search vs Exponential Search
Across our 4 test inputs, Interpolation Search needed 6 comparisons in total versus 25 for Exponential Search. On average Interpolation Search runs in O(log log n) time and Exponential Search in O(log n).
Head-to-head on identical inputs (comparisons)
| Input | Interpolation Search | Exponential Search |
|---|---|---|
| Target is first | 1 | 1 |
| Target in the middle | 2 | 7 |
| Target is last | 1 | 9 |
| Target absent | 2 | 8 |
Complexity
| Interpolation Search | Exponential Search | |
|---|---|---|
| Average time | O(log log n) | O(log n) |
| Worst time | O(n) | O(log n) |
| Space | O(1) | O(1) |
| Stable | No | No |
When to use Interpolation Search
Large sorted arrays whose values are roughly uniformly distributed (IDs, timestamps).
When to use Exponential Search
Unbounded or very large sorted lists, or when the target is likely near the start.