Algorithms · Visualized

Jump Search

Searching Algorithms

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

Jump Search works on sorted arrays by jumping ahead in fixed-size blocks (commonly √n) instead of checking one element at a time. Time: O(√n) average, O(√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).

Jump Search

Searching

Jump Search works on sorted arrays by jumping ahead in fixed-size blocks (commonly √n) instead of checking one element at a time. Once it finds a block where the target could be, it does a simple linear search inside just that block.

How Jump Search Works

  1. Decide a block/jump size, typically the square root of the array length.
  2. Jump forward by that block size, checking the value at each jump point, until you find a block whose last element is ≥ the target (or you reach the end).
  3. Once the right block is found, step back to the start of that block.
  4. Perform a linear search within that block to find the exact target.
  5. If the target isn't in the block, it's not in the array.

Jump Search Worked Example

Input: {array: [1, 4, 9, 12, 15, 19, 23, 28, 33, 41], target: 28, blockSize: 3}

Jump to index2 (9): 9<28, keep jumping. Index5 (19): 19<28, keep jumping. Index8 (33): 33≥28, stop jumping — target is in the block before index8. Linear search from index5 to index8: 19,23,28 → found 28 at index7.

Jump SearchO(√n)
Jump ahead in √n blocks, then linear-search the one block that can hold the target.
prev
1
0
4
1
9
2
step
12
3
15
4
19
5
23
6
28
7
33
8
41
9
Step 1 / 7
Default Current / Compare Swap / Write Settled Active / Path Pivot / Reject Locked (hollow) Target
Jump Search: block size √n = 3. Jump ahead in blocks of 3.
Python · Searching Algorithms in Code
import math

def jump_search(a, target):
    n = len(a)
    step = int(math.sqrt(n))
    prev = 0
    while a[min(step, n) - 1] < target:
        prev = step
        step += int(math.sqrt(n))
        if prev >= n:
            return -1
    for i in range(prev, min(step, n)):
        if a[i] == target:
            return i
    return -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.

Jump Search Time & Space Complexity

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

When to Use Jump Search

  • Sorted arrays where jumping back is expensive (e.g. some storage systems), so you want fewer 'seek' operations than binary search's random-access jumps but faster than linear search.
  • A middle-ground algorithm taught to illustrate block-based search strategies.

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.