Algorithms · Visualized

Exponential Search

Searching Algorithms

Six search strategies on a sorted array — from the obvious linear scan to log-time binary search and beyond.

Exponential Search finds a range where the target might exist by repeatedly doubling an index (1, 2, 4, 8, 16...) until it overshoots the target's value, then runs Binary Search within that bounded range. Time: O(log n) average, O(log n) worst; space: O(1).

Big-O: Binary O(log n), Linear O(n), Jump O(√n), Interpolation O(log log n) avg, Exponential O(log n).

Exponential Search

Searching

Exponential Search finds a range where the target might exist by repeatedly doubling an index (1, 2, 4, 8, 16...) until it overshoots the target's value, then runs Binary Search within that bounded range. It's especially useful for unbounded or very large sorted arrays.

How Exponential Search Works

  1. Check if the first element is the target; if so, return it.
  2. Starting from index 1, keep doubling the index (1, 2, 4, 8, ...) as long as the value there is less than the target and you're still within bounds.
  3. Once the value at the current index is ≥ target (or you go out of bounds), you now have a range: from the previous index to the current one.
  4. Run Binary Search within that specific range to locate the exact position of the target.
  5. Return the result of the binary search (found index, or not found).

Exponential Search Worked Example

Input: {array: [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21], target: 15}

Check index1 (3): 3<15, double to index2 (5): <15, double to index4 (9): <15, double to index8 (17): 17≥15, stop. Range is index4 to index8. Binary search within [9,11,13,15,17] finds 15 at index7.

Exponential SearchO(log n)
Double the index until past the target, then binary search the bounded range.
1
0
3
1
5
2
7
3
9
4
11
5
13
6
15
7
17
8
19
9
21
10
Step 1 / 8
Default Current / Compare Swap / Write Settled Active / Path Pivot / Reject Locked (hollow) Target
Exponential Search for 15: double the index until we pass the target.
Python · Searching Algorithms in Code
def exponential_search(a, target):
    if a[0] == target:
        return 0
    i = 1
    n = len(a)
    while i < n and a[i] <= target:
        i *= 2
    return binary_search(a, target, i // 2, min(i, n) - 1)

Behind the Scenes Execution

Press ▶ Run in the visualizer — the call stack, registers and memory will replay here in sync with the code, line by line.

Exponential Search Time & Space Complexity

BestO(1)
AverageO(log n)
WorstO(log n)
SpaceO(1)

When to Use Exponential Search

  • Searching in unbounded or very large sorted arrays/streams where you don't know the size in advance.
  • Slightly faster than plain binary search when the target is near the beginning of the array.

Recommended resourcesAffiliate links · may earn us a commission

Recommended for learners

Structured coding coursesVideo courses that pair well with visual practice — pick one language and go deep.Browse courses Classic DSA interview booksThe reference books interviewers themselves learned from — great next to the visualizers.See the books Cloud hosting for side projectsShip the portfolio project that gets you hired — free credits for new accounts.Claim credits

Keep the momentum going

Step through a related structure, pattern or course — the ideas reinforce each other and stick faster.