Jump Search - The Block Hopping Algorithm

Published on Tuesday, June 9, 2026

Imagine you’re reading a physical dictionary. Instead of scanning every single word from “A” to “Z,” you flip through whole chunks at a time — maybe 50 pages at once — until you overshoot the word you’re looking for, then you scan backwards a few pages to find it. That intuitive shortcut is the idea behind Jump Search.

Jump Search is a searching algorithm designed specifically for sorted arrays. It sits in an interesting middle ground: faster than linear search’s O(n)O(n) brute-force scan, but simpler (and in some contexts more practical) than binary search’s O(log⁡n)O(\log n) recursive halving. Its time complexity is O(n)O(\sqrt{n}) — and that square root is not a coincidence. It emerges directly from the optimal choice of block size.

A Brief History

Jump search was developed in the 1970s as a deliberate middle ground between linear search (O(n)O(n)) and binary search (O(log⁡n)O(\log n)). As computing evolved, engineers working with tape drives, sequential-access storage, and early disk systems noticed a real-world constraint that binary search ignored: jumping backward in memory is expensive.

Binary search is theoretically optimal for random-access memory, but on storage media where seeking backward takes significant time — think magnetic tape, where rewinding is slow — jump search offered a compelling alternative. By only ever moving forward through blocks and doing a small backward linear scan within a single block, jump search minimises costly reverse seeks.

The algorithm’s elegance lies in how the optimal block size falls out of the mathematics naturally, which I will explore shortly.

How It Works

Jump search operates on a sorted array in two phases: a forward jumping phase to identify the target block, and a backward linear scan within that block.

Here are the steps:

  1. Choose the block size m=⌊n⌋m = \lfloor\sqrt{n}\rfloor, where nn is the length of the array. This is the mathematically optimal jump step, as I will show in the complexity analysis.

  2. Jump forward in blocks. Compare the element at index mm, then 2m2m, then 3m3m, and so on — until you find an element that is greater than or equal to the target, or you reach the end of the array.

  3. If you’ve overshot (or reached the end), step back one block. You now know the target, if it exists, must lie somewhere between the previous jump position and the current one.

  4. Perform a linear scan backward from the current position toward the previous jump position, checking each element against the target.

  5. Return the index if the element is found, or signal that the target is not present if you exhaust the block without a match.

Here is a concrete example. Suppose you have an array of 16 elements and you are searching for the value 55:

Index: 0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15
Value: 2   5   8  12  18  23  31  40  55  62  70  78  85  91  95  99

Block size: ⌊16⌋=4\lfloor\sqrt{16}\rfloor = 4

  • Jump to index 4 → value 18 → less than 55, keep jumping.
  • Jump to index 8 → value 55 → equal to target! Found at index 8.

In this case, I got lucky and the element was exactly on a block boundary. If the target had been 62, I would have jumped to index 12 (value 85), overshot, then scanned backward: index 11 (78), 10 (70), 9 (62) — found.

Time Complexity

O(n)O(\sqrt{n})

The O(n)O(\sqrt{n}) time complexity is derived directly from the choice of block size. Let’s see why n\sqrt{n} is optimal.

Suppose the array has nn elements and I choose a block size of mm. In the worst case:

  • The jumping phase performs ⌈n/m⌉\lceil n/m \rceil comparisons (one per block).
  • The linear scan phase performs at most m−1m - 1 comparisons within the final block.

The total worst-case comparisons are:

nm+m−1\frac{n}{m} + m - 1

To minimise this, take the derivative with respect to mm and set it to zero:

ddm(nm+m)=−nm2+1=0\frac{d}{dm}\left(\frac{n}{m} + m\right) = -\frac{n}{m^2} + 1 = 0

Solving gives m=nm = \sqrt{n}. Substituting back:

nn+n=n+n=2n\frac{n}{\sqrt{n}} + \sqrt{n} = \sqrt{n} + \sqrt{n} = 2\sqrt{n}

So the worst-case number of comparisons is 2n2\sqrt{n}, which is O(n)O(\sqrt{n}).

This is a rare case where the optimal parameter value falls out of the math cleanly, and it’s one of the things that makes jump search feel elegant. You’re not choosing n\sqrt{n} arbitrarily — the mathematics demands it.

For a sorted array of 1,000,000 elements, jump search needs at most around 2,000 comparisons — far better than a linear scan’s 1,000,000, though not as sharp as binary search’s ~20.

Space Complexity

O(1)O(1)

Jump search is an in-place algorithm. It uses only a constant amount of extra memory: a few variables to track the current index, the previous jump position, and the block size. No recursion stack, no auxiliary arrays.

This constant space characteristic makes jump search well-suited for memory-constrained environments where allocating auxiliary space is undesirable.

Advantages and Disadvantages

Advantages:

  • Better than linear search. O(n)O(\sqrt{n}) handily beats O(n)O(n) for large arrays. Searching a million-element array takes ~1,000 jumps instead of up to 1,000,000 element checks.
  • Simpler than binary search in some implementations. The forward-only jumping pattern is conceptually straightforward and can be easier to reason about.
  • Preferred when backward traversal is expensive. On storage media or data structures where seeking backward is costly — tape drives, linked lists traversed from a known checkpoint, or certain I/O systems — jump search’s single backward scan per search is a significant advantage over binary search, which may jump back and forth repeatedly.
  • Cache-friendly forward movement. The jumping phase reads memory in a strictly forward direction, which can be friendlier to hardware prefetching than binary search’s unpredictable jumps.

Disadvantages:

  • Requires a sorted array. Like binary search, jump search is completely inapplicable to unsorted data. If sorting is not already done, the O(nlog⁡n)O(n \log n) sort cost dominates.
  • Slower than binary search on random-access memory. O(n)O(\sqrt{n}) grows faster than O(log⁡n)O(\log n). For large nn on RAM, binary search wins decisively.
  • Fixed block size is not adaptive. Jump search does not adapt to the distribution of data. Interpolation search, for instance, can outperform jump search on uniformly distributed data.
  • Not suitable for very small arrays. For tiny arrays (fewer than ~20 elements), simple linear search is often faster in practice due to lower overhead and better cache behaviour.

Jump search earns its place in a specific set of circumstances:

  • You have a sorted array or sorted sequential data structure — this is non-negotiable.
  • Backward traversal is expensive — if your storage or data structure makes backward movement significantly costlier than forward movement, jump search’s single-direction jumping phase is a genuine win over binary search.
  • You want something between linear and binary search — perhaps your environment doesn’t support efficient division/modulo operations, or the recursive overhead of binary search is undesirable.
  • Memory is tight — the O(1)O(1) space requirement makes it appropriate in constrained environments.

If you’re working with ordinary in-memory sorted arrays and backward traversal is cheap, binary search’s O(log⁡n)O(\log n) will almost always be the better choice. But jump search remains a useful tool to recognise: its O(n)O(\sqrt{n}) complexity and forward-only traversal pattern solve a real class of problems that binary search handles less gracefully.

Conclusion

Jump search is a hybrid algorithm at heart — it combines the forward momentum of a coarse jump phase with the fine-grained precision of a linear scan, yielding an O(n)O(\sqrt{n}) algorithm that elegantly balances speed and simplicity.

Its story is also a reminder that the right algorithm depends on more than just asymptotic complexity. The real-world cost of backward seeks in sequential storage gave jump search a practical edge that pure theory would not predict. Understanding why jump search exists — not just what it does — is what distinguishes a good engineer from a great one.

Key takeaways:

  • Jump search works only on sorted arrays.
  • The optimal block size is ⌊n⌋\lfloor\sqrt{n}\rfloor, derived mathematically, giving O(n)O(\sqrt{n}) time complexity.
  • Space complexity is O(1)O(1) — no extra memory required.
  • It is better than linear search (O(n)O(n)) but generally worse than binary search (O(log⁡n)O(\log n)) on random-access memory.
  • Its real advantage appears when backward traversal is expensive, such as on tape drives or sequential storage systems.

lightning-logo
Unleash the power of performance by comparing your code. Performance. Unbound.