Search Algorithms

Explore and compare different searching algorithms with detailed complexity analysis.

None

Linear Search

Simple sequential search through all elements one by one.

Best:O(1)
Average:O(n)
Worst:O(n)
Space:O(1)
Best for:
Small datasets, unsorted data
View Details
Sorted array

Binary Search

Divide and conquer algorithm that repeatedly divides search interval in half.

Best:O(1)
Average:O(log n)
Worst:O(log n)
Space:O(1)
Best for:
Large sorted datasets
View Details
Sorted array

Jump Search

Jump ahead by fixed steps, then perform linear search in the block.

Best:O(1)
Average:O(√n)
Worst:O(√n)
Space:O(1)
Best for:
Sorted data, better than linear
View Details
Sorted array, uniformly distributed

Interpolation Search

Improved binary search using position estimation based on value.

Best:O(1)
Average:O(log log n)
Worst:O(n)
Space:O(1)
Best for:
Uniformly distributed sorted data
View Details
Sorted array

Exponential Search

Find range where element is present, then do binary search in that range.

Best:O(1)
Average:O(log n)
Worst:O(log n)
Space:O(1)
Best for:
Unbounded/infinite arrays
View Details
Sorted array

Ternary Search

Divide-and-conquer algorithm that divides array into three parts.

Best:O(1)
Average:O(log₃ n)
Worst:O(log₃ n)
Space:O(1)
Best for:
Finding maximum/minimum in unimodal functions
View Details

Quick Comparison

AlgorithmBestAverageWorstSpaceRequirement
Linear SearchO(1)O(n)O(n)O(1)None
Binary SearchO(1)O(log n)O(log n)O(1)Sorted array
Jump SearchO(1)O(√n)O(√n)O(1)Sorted array
Interpolation SearchO(1)O(log log n)O(n)O(1)Sorted array, uniformly distributed
Exponential SearchO(1)O(log n)O(log n)O(1)Sorted array
Ternary SearchO(1)O(log₃ n)O(log₃ n)O(1)Sorted array
💡 Tip
For small datasets (<100 items), Linear Search is often fast enough and simpler to implement.
⚡ Performance
Binary Search is the go-to choice for large sorted datasets, offering O(log n) performance.
🎯 Use Case
Interpolation Search works best with uniformly distributed data for even better performance.