Back to All Algorithms
Jump Search
Category: Searching | Time: O(√n) | Space: O(1)
Visualization
Visual representation of the data structure
About Jump Search

A searching algorithm for sorted arrays. The basic idea is to check fewer elements than linear search by jumping ahead by fixed steps and then doing a linear search in the identified block.

Code Editor
The code is for reference. Editing it won't affect the visualization.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Variable State
{
  "arr": "[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]",
  "target": 55,
  "n": 16
}
Jump Search: How It Works
Last updated October 28, 2026

Overview

Jump Search is a middle ground between linear and binary search for sorted arrays. Instead of checking every element, it jumps ahead in blocks of size √n until it passes the target, then does a short linear scan backwards inside the last block.

With a block size of √n there are at most √n jumps and at most √n steps in the final scan, so the total is O(√n). It is slower than binary search in theory, but it only ever moves forward through the data, which can matter when stepping backwards is expensive.

The default array is the first 16 Fibonacci numbers and the target is 55, so the block size is 4. The search checks the ends of blocks at indices 3 (value 2), 7 (13) and 11 (89). Since 89 is past the target, it scans forward from index 8 and finds 55 at index 10.

Step by step

  1. Set step = floor(√n) and prev = 0.
  2. While the last element of the current block, arr[min(step, n) - 1], is less than the target, set prev = step and advance step by √n. If prev >= n, return -1.
  3. Scan linearly from prev while arr[prev] < target, stopping at the end of the block.
  4. If arr[prev] equals the target, return prev; otherwise return -1.

Complexity

CaseCostWhy
Best caseO(1)The target is in the first block, near its start.
Average caseO(√n)About √n/2 jumps plus √n/2 scan steps.
Worst caseO(√n)√n jumps plus a full √n-element scan.
Extra spaceO(1)Two indices.

When to use it

  • Sorted data on media where jumping back is costly, such as tape or some sequential storage.
  • When you want something faster than linear search but simpler than binary search.
  • As a building block for block-based indexes, where each block is scanned linearly.

Common mistakes

  • The block size must be √n for the O(√n) bound; a fixed small step makes it linear.
  • Forgetting min(step, n) reads past the end of the array on the final jump.
  • Like binary search, it requires sorted input.
Worked Example: Jump Search Dry Run
Generated from the same trace that drives the visualizer above, using the default input.

A dry run is the best way to check your understanding of Jump Search: follow each row, predict the next one, and compare. The run below takes 21 steps in total. Steps that only re-print loop counters are left out so the decisions stand out. The Line column refers to the line numbers in the code listing above.

Input
0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610
Target
55
Result
return value = 10
StepLineArrayWhat happens
11[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]target = 55, n = 16
44[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]condition = 2 < 55
77[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]prev = 4, n = 16, condition = 4 >= 16
84[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]condition = 13 < 55
117[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]prev = 8, n = 16, condition = 8 >= 16
124[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]condition = 89 < 55
1311[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]prev = 8, condition = 21 < 55
1513[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]prev = 9, step = 12, n = 16, condition = 9 == 12
1611[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]prev = 9, condition = 34 < 55
1813[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]prev = 10, step = 12, n = 16, condition = 10 == 12
1911[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]prev = 10, condition = 55 < 55
2017[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]prev = 10, condition = 55 === 55
2118[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]return value = 10
Frequently Asked Questions
About Jump Search

What is Jump Search?

Jump Search is a searching algorithm for sorted arrays. The basic idea is to check fewer elements than linear search by jumping ahead by fixed steps and then doing a linear search in the identified block.

How does Jump Search work?

It works by jumping ahead by a fixed step size (typically √n). It compares the element at the jumped position. If it's smaller than the target, it jumps again. If it's larger, it performs a linear search in the block between the previous and current jump positions.

What is the optimal jump size?

The optimal jump size is √n, where n is the number of elements in the array. This provides the best worst-case performance.

What is the time complexity of Jump Search?

The time complexity is O(√n). In the worst case, we perform n/√n jumps and then √n comparisons for the linear search, making it √n + √n = 2√n operations.

When is Jump Search better than Binary Search?

Binary Search is generally better (O(log n) vs O(√n)). However, Jump Search can be advantageous when jumping back is expensive. In some systems, memory access patterns might favor jumping forward only.

Does Jump Search require a sorted array?

Yes, just like Binary Search, Jump Search requires the array to be sorted.

What is the space complexity of Jump Search?

The space complexity is O(1) because it operates in-place on the given array.

How does it compare to Linear Search?

It is much faster than Linear Search (O(√n) vs O(n)) for large arrays.

Can Jump Search be used for linked lists?

It's not practical for standard linked lists due to the lack of random access needed to perform the 'jumps' efficiently.

What happens if the element is not found?

If the linear search phase completes without finding the element, or if the initial jumps go past the end of the array without finding a block that could contain the element, it is concluded that the element is not present.

Where can I learn more?

You can find a more detailed explanation on GeeksforGeeks.