Exponential Search, explained step by step

Exponential Search finds a range containing the target by doubling an index (1, 2, 4, 8 …), then runs Binary Search inside that range.

Intuition: Check house numbers 1, 2, 4, 8, 16… until you pass your number, then search that street block.

How it works

  1. Check index 0.
  2. Double the bound while arr[bound] < target.
  3. Binary search between bound/2 and bound.

Complexity

  • Best: O(1)
  • Average: O(log n)
  • Worst: O(log n)
  • Space: O(1)
  • Stable: no

When to use it

Unbounded or very large sorted lists, or when the target is likely near the start.

Interview questions

  • How would you search an infinite sorted stream?
  • Why is it O(log i) where i is the target index?

Compare Exponential Search

Open Exponential Search in the visualiser