Skip to content

2. Binary Search and Ordered Search

Binary search and its ordered-search relatives: interpolation, Fibonacci, rotated-array, matrix, parametric, and offline variants.

indexslugname
21binary-searchBinary Search
22iterative-binary-searchIterative Binary Search
23recursive-binary-searchRecursive Binary Search
24lower-boundLower Bound
25upper-boundUpper Bound
26equal-range-searchEqual Range Search
27first-true-binary-searchFirst True Binary Search
28last-true-binary-searchLast True Binary Search
29binary-search-on-answerBinary Search on Answer
30exponential-searchExponential Search
31galloping-searchGalloping Search
32interpolation-searchInterpolation Search
33uniform-binary-searchUniform Binary Search
34fibonacci-searchFibonacci Search
35jump-searchJump Search
36ternary-search-discreteDiscrete Ternary Search
37ternary-search-continuousContinuous Ternary Search
38rotated-array-searchRotated Array Search
39rotated-array-minimum-searchRotated Array Minimum Search
40bitonic-array-searchBitonic Array Search
41peak-finding-one-dimensionalOne Dimensional Peak Finding
42peak-finding-two-dimensionalTwo Dimensional Peak Finding
43matrix-binary-searchMatrix Binary Search
44saddleback-searchSaddleback Search
45sorted-matrix-searchSorted Matrix Search
46fractional-cascading-searchFractional Cascading Search
47binary-lifting-searchBinary Lifting Search
48powers-of-two-searchPowers of Two Search
49parametric-searchParametric Search
50parallel-binary-searchParallel Binary Search
51offline-binary-searchOffline Binary Search
52parallel-binary-search-dsuParallel Binary Search with DSU
53continuous-bisection-methodBisection Method
54monotone-predicate-searchMonotone Predicate Search
55integer-square-root-binary-searchInteger Square Root by Binary Search
Binary SearchSearch a sorted array by repeatedly halving the search interval.
3 min
Iterative Binary SearchBinary search implemented using a loop without recursion.
2 min
Recursive Binary SearchBinary search implemented using recursion over a shrinking interval.
2 min
Lower BoundFind the first position where a value can be inserted without violating sorted order.
2 min
Upper BoundFind the first index where elements become strictly greater than a given value.
2 min
Equal RangeFind the range of indices containing all occurrences of a value in a sorted array.
3 min
First True Binary SearchFind the first position where a monotone predicate becomes true.
2 min
Last True Binary SearchFind the last position where a monotone predicate remains true.
3 min
Binary Search on AnswerFind an optimal value by binary searching a monotone feasibility condition.
3 min
Exponential SearchLocate a search interval by exponential growth, then apply binary search.
3 min
Galloping SearchExpand the search range exponentially from a starting position, then apply binary search.
3 min
Interpolation SearchSearch a sorted numeric array by estimating the likely position of the target from its value.
4 min
Uniform Binary SearchBinary search variant that uses precomputed step sizes instead of dynamic midpoint calculation.
3 min
Fibonacci SearchSearch a sorted array using Fibonacci numbers to divide the range.
3 min
Jump SearchSearch a sorted array by jumping in fixed steps, then performing a linear scan within a block.
3 min
Discrete Ternary SearchFind the maximum or minimum of a unimodal function defined on discrete indices.
3 min
Continuous Ternary SearchFind the maximum or minimum of a unimodal function over a continuous domain.
3 min
Rotated Array SearchSearch a value in a sorted array that has been rotated around an unknown pivot.
4 min
Rotated Array Minimum SearchFind the smallest element in a sorted array that has been rotated around an unknown pivot.
3 min
Bitonic Array SearchSearch a value in an array that first increases and then decreases.
4 min
One Dimensional Peak FindingFind an element that is at least as large as its immediate neighbors.
3 min
Two Dimensional Peak FindingFind a peak element in a 2D grid using divide and conquer.
4 min
Matrix Binary SearchSearch a row-major sorted matrix by treating it as a virtual sorted array.
3 min
Saddleback SearchSearch a matrix sorted by rows and columns using a monotone path from a corner.
3 min
Sorted Matrix SearchSearch a matrix sorted by rows and columns using divide and conquer.
4 min
Fractional Cascading SearchSpeed up repeated binary searches across related sorted lists by linking sampled elements between lists.
3 min
Binary Lifting SearchFind a target state by jumping through powers of two in a precomputed lifting table.
4 min
Powers of Two SearchSearch for a boundary by trying decreasing jumps whose lengths are powers of two.
3 min
Parametric SearchConvert an optimization problem into a decision problem and search the parameter space.
4 min
Parallel Binary SearchAnswer many offline queries by searching their answers simultaneously with shared checks.
4 min
Offline Binary SearchAnswer many monotone queries by processing them together after all input is known.
5 min
Parallel Binary Search with DSUAnswer offline connectivity queries by combining parallel binary search with a disjoint set union.
6 min
Bisection MethodFind a root of a continuous function by repeatedly halving an interval where the function changes sign.
4 min
Monotone Predicate SearchFind the boundary where a Boolean predicate changes value over an ordered domain.
3 min
Integer Square RootCompute the floor of the square root of a nonnegative integer using binary search.
3 min