Overview & Concept
Exponential Search (Doubling Search) finds the range in which a target element resides by testing powers of 2 (1, 2, 4, 8, 16...) until an element greater than the target is found, then performs a Binary Search within that bounded range. It is especially useful for unbounded or infinite sorted arrays.
How It Works
Range Bounding: Starts at index 1 and repeatedly doubles i *= 2 until A[i] >= target or i >= n.
Subarray Binary Search: Executes binary search on the isolated sub-range [i/2, min(i, n - 1)].
O(log i) Time: Where i is the actual index position of the target element.
Step-by-Step Execution
Asymptotic Complexity Analysis
| Metric | Best Case | Average Case | Worst Case | Space Complexity |
|---|---|---|---|---|
| Complexity Bound | O(1) | O(log i) | O(log i) | O(1) |
| Explanation | Optimal input arrangement minimizing operations. | Expected time for uniformly distributed randomized inputs. | Adversarial degenerate conditions requiring full traversal. | Auxiliary memory allocated beyond original input size. |
Pseudocode & Invariants
procedure exponentialSearch(A, target):
if A[0] == target: return 0
bound = 1
while bound < n and A[bound] < target:
bound *= 2
return binarySearch(A, target, bound / 2, min(bound, n - 1))- Range Bounding Invariant: Target resides strictly in [bound / 2, min(bound, n - 1)].
Advantages & Disadvantages
Key Advantages
- •Excels when target is near the beginning of the array: runs in O(log i) time instead of O(log n).
- •Works on unbounded or infinite arrays where the length n is not known beforehand.
Trade-offs & Limitations
- •Requires sorted data.
Real-World Applications
Infinite Stream Lookups
Searching sorted continuous data streams with unknown total length.
Unbounded Disk Logs
Searching append-only sorted log files.
Decision Guide: When to Use
Ideal Scenarios
- ✓When searching unbounded arrays or when target is likely near the start.
Consider Alternatives When
- ✕When array size is known and target is uniformly distributed (standard Binary Search is simpler).
Explore Related Algorithms
Compare trade-offs and complexity across complementary tools in AlgoViz.