Search Algorithms
Linear, binary, Jump, Interpolation and Ternary Search with lo/mid/hi pointers on a sorted bar array.
- Linear SearchInteractive linear search: compares every index to the target value one after the other. Works on unsorted arrays and streams, runs in O(n) worst case.
- Binary SearchInteractive binary search: halves the search range using the middle and shifts lo or hi. Requires a sorted array, runs in O(log n) with constant extra memory.
- Jump SearchInteractive Jump Search: jumps through a sorted array in √n strides and then scans the right block linearly. A sweet spot between O(n) and O(log n).
- Interpolation SearchInteractive interpolation search: estimates the target position via linear interpolation. Extremely fast on uniformly distributed values, worst case still O(n).
- Ternary SearchInteractive ternary search: splits the range at m1 and m2 into three thirds. O(log₃ n), asymptotically equal to binary search; classic use case are unimodal functions.