Exponential (galloping) search locates a value x in a sorted array by probing positions with exponentially growing distance (1, 3, 7, …, 2^i − 1) until an element ≥ x is found and then binary searching the last interval, in O(log d) time for d the position of x.
The search did not stop at jk−1, so jk−1<d, i.e. 2k−1−1<d, hence 2k−1≤d and k≤log2d+1. The doubling phase takes O(k)=O(logd) steps.
Hence jk=2k−1≤2log2d+1−1<2d. The binary search halves its interval (of length <2d) in every step, so it takes O(log(2d))=O(log2+logd)=O(logd) steps.
Both phases together: O(logd). ■
Proof
After k jumps the probed position is 0+1+2+…+2k−1=2k−1. The search stops there, so 2k−1≥i, i.e. k≥log2(i+1).
It did not stop one jump earlier, at position 2k−1−1, so 2k−1−1<i, i.e. k−1<log2(i+1).
Hence k is the smallest integer ≥log2(i+1): k=⌈log2(i+1)⌉. ■
Doubling variant.DBIS Exam WS2223 (not published) (Task 1.1) probes the positions 0,1,2,4,8,… (i = max(2 * i, 1)) instead. For j the smallest index with A[j]=x this returns an index i with j≤i≤2j in O(log(1+j)) time; the 1+ handles j=0.
Use in list intersection. Searching each element of the shorter list in the longer one with galloping search, each search starting where the previous one stopped, gives the O(k⋅log(1+n/k)) intersection algorithm (List Intersection > 3. Galloping (Exponential) Search Intersection).
Compared with plain binary search over the whole array (O(logn)), the cost depends only on the distance d to the target, not on the array length n; this pays off when the target is near the start.
Doubling phase: probe A[0]=2, A[1]=3, A[3]=8 (all <34), then A[7]=55≥34: stop after k=3 jumps (⌈log2(7+1)⌉=3 with i=7 the first position with A[i]>34).
Binary search in positions 4..7: A[5]=21<34, then A[6]=34: found.