Bölüm 3 · Simülatör

Exponential Search

← Bölüm 3
PhaseReady
bound–
lo–
hi–
mid–
Probes0

    Probe sequence: –

    Exponential Search

    First expand the search boundary exponentially, then perform binary search inside the discovered range.

    How to use

    • Enter a target and press Search to animate the whole search, or press Step to advance one comparison at a time.
    • Reset clears the run; New Array draws a new sorted array of 20 distinct values.
    • Red labels above the cells mark the probed bounds 1, 2, 4, 8, 16; the blue bar shows the current binary-search interval [lo, hi].

    Algorithm

    1. If A[0] equals the target, stop.
    2. Start with bound = 1 and double it while bound < n and A[bound] < target.
    3. The target, if present, lies in A[bound/2 … min(bound, n − 1)]; run binary search there.

    Complexity

    If the target is at position i, the doubling phase takes about log₂ i steps and the binary search works on a range of size about i, so the total time is O(log i) ≤ O(log n) with O(1) extra space. It is useful for unbounded or very large sorted lists, where the target is near the beginning.