Linear Search vs Exponential Search

Across our 4 test inputs, Exponential Search needed 25 comparisons in total versus 42 for Linear Search. On average Linear Search runs in O(n) time and Exponential Search in O(log n). Linear Search is stable; Exponential Search is not. Exponential Search only works on sorted data.

Head-to-head on identical inputs (comparisons)

InputLinear SearchExponential Search
Target is first11
Target in the middle97
Target is last169
Target absent168

Complexity

Linear SearchExponential Search
Average timeO(n)O(log n)
Worst timeO(n)O(log n)
SpaceO(1)O(1)
StableYesNo

When to use Linear Search

Unsorted arrays, small datasets, or when you need to find all occurrences.

When to use Exponential Search

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