The idea
Key formulas
Midpoint index
Worst-case probes
Loading lessons…
Just a moment, getting everything ready. The first load can take up to a minute.
Data structures and algorithms
Trace how binary search halves a sorted range and compare its probes with log2 n.
Pseudocode
Binary search requires sorted values. It compares the target with the middle item and discards the half that cannot contain the target. Repeating this process takes logarithmically many probes.