SearchingAnimated
Jump Search
Jump ahead in blocks of √n, then scan the one block that can hold the target.
Time
O(√n)
Extra space
O(1)
Use it for
Sorted data where moving backwards is costly.
How it works
- On a sorted list, choose a jump size of about √n.
- Jump ahead block by block until the value at the end of a block is ≥ the target.
- The target, if present, must be inside that block.
- Do a linear scan inside the block.
- About 2√n steps in the worst case: between linear and binary search, but only moves forward.
Watch it run
Loading animation…