Exponential Search vs Ternary Search

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

Head-to-head on identical inputs (comparisons)

InputExponential SearchTernary Search
Target is first17
Target in the middle75
Target is last97
Target absent89

Complexity

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

When to use Exponential Search

Unbounded or very large sorted lists, or when the target is likely near the start.

When to use Ternary Search

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