Jump Search vs Ternary Search

Across our 4 test inputs, Jump Search needed 21 comparisons in total versus 28 for Ternary Search. On average Jump Search runs in O(√n) time and Ternary Search in O(log₃ n).

Head-to-head on identical inputs (comparisons)

InputJump SearchTernary Search
Target is first27
Target in the middle45
Target is last87
Target absent79

Complexity

Jump SearchTernary Search
Average timeO(√n)O(log₃ n)
Worst timeO(√n)O(log₃ n)
SpaceO(1)O(1)
StableNoNo

When to use Jump Search

Sorted data where jumping backwards is expensive (e.g. linked storage or tape-like media).

When to use Ternary Search

Finding the peak/valley of a unimodal function; for plain sorted lookups binary search is usually better.