AiTechWorlds
AiTechWorlds
Watch Exponential Search double a range bound then binary search inside it, with synced code and step explanations.
def exponential_search(a, target):
if a[0] == target: return 0
n = len(a); bound = 1
while bound < n and a[bound] < target: bound *= 2
lo, hi = bound // 2, min(bound, n - 1)
while lo <= hi:
mid = (lo + hi) // 2
if a[mid] == target: return mid
if a[mid] < target: lo = mid + 1
else: hi = mid - 1
return -1Exponential Search doubles a range bound until it passes the target, then runs binary search inside that range — ideal for unbounded or very large sorted arrays.
| Best | O(1) |
| Average | O(log n) |
| Worst | O(log n) |
| Space | O(1) |
| Requires sorted | Yes |
The Exponential Search Visualizer animates how Exponential Search works: it doubles a range bound (1, 2, 4, 8, …) until the bound passes the target, then runs Binary Search within the found range. Exponential Search runs in O(log n) time, uses O(1) space, requires a sorted array, and is ideal for unbounded or very large sorted sequences.
Set a target
Type the value to search for, or click New Array to randomize the sorted data and target.
Play the animation
Press Play to watch the bound double, then the binary search narrow the range.
Step and scrub
Use Step Forward/Back or the timeline to study each doubling.
Read the synced code
The highlighted pseudocode line tracks the doubling and binary search; switch tabs for C++, Java, Python, or JavaScript.
100% Private — No Server Required
All processing happens directly in your browser. No data is uploaded, stored, or transmitted to any server.
Last reviewed on June 14, 2026 by the AiTechWorlds Tools Team. All processing runs locally in your browser.