Skip to content
StackDecode
SearchingAnimated

Exponential Search

Double an index until it passes the target, then binary search that range.

Time

O(log i)

Extra space

O(1)

Use it for

Unbounded or very large sorted lists.

How it works

  1. Useful when the list is huge or unbounded.
  2. Start at index 1 and keep doubling the index (1, 2, 4, 8…) until a[index] ≥ target or you pass the end.
  3. The target must lie between index/2 and index.
  4. Run binary search on just that range.
  5. Total cost is O(log i), where i is the position of the target.

Watch it run

Loading animation…