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
- Useful when the list is huge or unbounded.
- Start at index 1 and keep doubling the index (1, 2, 4, 8…) until a[index] ≥ target or you pass the end.
- The target must lie between index/2 and index.
- Run binary search on just that range.
- Total cost is O(log i), where i is the position of the target.
Watch it run
Loading animation…