Oh My Algorithm
Algorithm Guidecomplexity: O(√n)

Jump Search

Jumps through a sorted array in blocks of size √n to narrow the range fast, then runs a linear search inside the candidate block. The jump cost is higher than binary search, but it wins on storage where moving backward is expensive (magnetic tape, disk).

01Jump Search

Starting jump search. With ten values, hop three slots (√n) at a time to find the block that could hold the target 45.

Three slots in, the value is 23, still below 45. It isn't in this block, so hop three more.

The next landing is 56 — past the target. If 45 exists, it is in the block we just skipped over.

Scan that block from its start. The first value, 34, is not the target.

The next value is 45 — a match. End the search.

Search complete · 45 sits at index 4. Three hops plus two scanned values: five comparisons in all.

5
12
23
34
45
56
67
78
89
98
1 / 6

02 Understand It Simply

For Everyone
🔑How It Works

Steps ahead √n slots at a time to find the block that could hold the target, then scans that block from its start.

💡In Plain Words

Jumps in √n-sized strides to find a candidate block quickly, then searches it linearly.

Good for media where backward seeks are costly.

📍Where It's Used
  • Sorted data
  • sequential-access media (tape
  • disk)

03 Python Implementation

A clean, readable reference implementation of the core logic of Jump Search.

core_implementation.py
import math

def jump_search(arr, target):
    n = len(arr)
    step = int(math.sqrt(n))
    prev = 0
    while arr[min(step, n) - 1] < target:
        prev = step
        step += int(math.sqrt(n))
        if prev >= n:
            return -1
    while arr[prev] < target:
        prev += 1
        if prev == min(step, n):
            return -1
    if arr[prev] == target:
        return prev
    return -1

04 Frequently Asked Questions

FAQ
What is Jump Search?+

Jumps through a sorted array in blocks of size √n to narrow the range fast, then runs a linear search inside the candidate block. The jump cost is higher than binary search, but it wins on storage where moving backward is expensive (magnetic tape, disk).

What is the time complexity of Jump Search?+

The time complexity of Jump Search is O(√n). Follow the step-by-step visualization to see exactly why.

Where is Jump Search used?+

Sorted data, sequential-access media (tape, disk).

What's a simple analogy for Jump Search?+

Steps ahead √n slots at a time to find the block that could hold the target, then scans that block from its start.