The optimal value of m is √n, where n is the length of the list L. Because both steps of the algorithm look at, at most, √n items the algorithm runs in O(√n) time. This is better than a linear search, but worse than a binary search. The advantage over the latter is that a jump search only needs to jump backwards once, while a binary can jump backwards up to log n times. This can be important if a jumping backwards takes significantly more time than jumping forward.
The algorithm can be modified by performing multiple levels of jump search on the sublists, before finally performing the linear search. For an k-level jump search the optimum block size ml for the lth level (counting from 1) is n(k-l)/k. The modified algorithm will perform k backward jumps and runs in O(kn1/(k+1)) time.
Input: An ordered list L, its length n and a search key s.
Output: The position of s in L, or nothing if s is not in L.
a ← 0
b ← ⌊√n⌋
while Lmin(b,n)-1 < s do
a ← b
b ← b + ⌊√n⌋
if a ≥ n then
while La < s do
a ← a + 1
if a = min(b,n)
if La = s then
A Chippy off the Old Block; Search of Another Gastronomic Hot Potato, Finola Lynch Visits an Award- Winning Erdington Chip Shop Looking for the Perfect Fish Supper
Aug 01, 1998; The expression, "marriages made in heaven" does not just apply to humans. What about fish and chips? There are few dishes as...