Binary Search vs Jump Search
Across our 4 test inputs, Binary Search needed 17 comparisons in total versus 21 for Jump Search. On average Binary Search runs in O(log n) time and Jump Search in O(√n). Binary Search is stable; Jump Search is not.
Head-to-head on identical inputs (comparisons)
| Input | Binary Search | Jump Search |
|---|---|---|
| Target is first | 4 | 2 |
| Target in the middle | 4 | 4 |
| Target is last | 5 | 8 |
| Target absent | 4 | 7 |
Complexity
| Binary Search | Jump Search | |
|---|---|---|
| Average time | O(log n) | O(√n) |
| Worst time | O(log n) | O(√n) |
| Space | O(1) | O(1) |
| Stable | Yes | No |
When to use Binary Search
Sorted arrays when O(log n) search time is needed. Foundation for many advanced algorithms.
When to use Jump Search
Sorted data where jumping backwards is expensive (e.g. linked storage or tape-like media).