Exponential Search visualization
Double a bound until it passes the target, then binary search inside that range.
Great for unbounded or very long lists: the doubling phase finds a range of size ~2i containing the target in O(log i) steps, then binary search finishes the job.
Complexity
Time: best O(1), average O(log i), worst O(log n). Space: O(1). Difficulty: Intermediate.
Pseudocode
procedure exponentialSearch(A, target):
if A[0] = target: return 0
bound ← 1
while bound < n and A[bound] < target: bound ← bound · 2
return binarySearch(A, bound/2, min(bound, n−1))
More searching algorithms
- Linear Search — Check every element from left to right until the target appears.
- Binary Search — Halve a sorted search range each step by comparing against the middle.
- Jump Search — Jump ahead √n at a time to find the right block, then scan it linearly.
- Interpolation Search — Guess where the target should be from its value, like looking up a name in a phone book.
- Ternary Search — Split a sorted range into thirds with two probes and keep the third that can hold the target.