Binary Search vs Interpolation Search

Across our 4 test inputs, Interpolation Search needed 6 comparisons in total versus 17 for Binary Search. On average Binary Search runs in O(log n) time and Interpolation Search in O(log log n). Binary Search is stable; Interpolation Search is not.

Head-to-head on identical inputs (comparisons)

InputBinary SearchInterpolation Search
Target is first41
Target in the middle42
Target is last51
Target absent42

Complexity

Binary SearchInterpolation Search
Average timeO(log n)O(log log n)
Worst timeO(log n)O(n)
SpaceO(1)O(1)
StableYesNo

When to use Binary Search

Sorted arrays when O(log n) search time is needed. Foundation for many advanced algorithms.

When to use Interpolation Search

Large sorted arrays whose values are roughly uniformly distributed (IDs, timestamps).