Overview & Concept
Jump Search (Block Search) searches a sorted array by jumping ahead by fixed steps of size m = ⌊√n⌋ until an element greater than the target is found, then performs a linear search backward within that block. It achieves O(√n) time complexity, bridging the gap between linear and binary search.
How It Works
Optimal Block Size: Step size m = ⌊√n⌋ mathematically minimizes total jumps and linear checks.
Block Skipping: Compares A[m], A[2m], A[3m]... to target to bypass blocks of elements.
Local Linear Search: Once A[k × m] > target, linear search scans backward from index (k - 1) × m.
Step-by-Step Execution
Asymptotic Complexity Analysis
| Metric | Best Case | Average Case | Worst Case | Space Complexity |
|---|---|---|---|---|
| Complexity Bound | O(1) | O(√n) | O(√n) | O(1) |
| Explanation | Optimal input arrangement minimizing operations. | Expected time for uniformly distributed randomized inputs. | Adversarial degenerate conditions requiring full traversal. | Auxiliary memory allocated beyond original input size. |
Pseudocode & Invariants
procedure jumpSearch(A, target):
m = floor(sqrt(n)); step = m; prev = 0
while A[min(step, n) - 1] < target:
prev = step; step += m
if prev >= n: return -1
for i = prev to min(step, n) - 1:
if A[i] == target: return i
return -1- Block Invariant: Target, if present, resides within index range [prev, min(step, n) - 1].
Advantages & Disadvantages
Key Advantages
- •O(√n) time is significantly faster than O(n) linear search.
- •Jumps strictly backward only once: ideal for systems where backward seeking is expensive.
Trade-offs & Limitations
- •Slower than Binary Search O(log n).
- •Requires sorted data.
Real-World Applications
One-Way Media / Tape Drives
Searching data streams where seeking forward is cheap but seeking backward is slow.
Decision Guide: When to Use
Ideal Scenarios
- ✓When jumping forward is substantially cheaper than jumping backward.
Consider Alternatives When
- ✕When full random access is available (Binary Search is strictly superior).
Explore Related Algorithms
Compare trade-offs and complexity across complementary tools in AlgoViz.