Binary Search
Definition
Search algorithm that narrows the search area in a sorted data set by repeated halving.
Binary search compares the searched value to the middle element of a sorted sequence. Depending on the comparison, only the left or right half is searched further. As a result, the number of necessary comparisons only increases logarithmically with the input size.
Simply explained
As with the dictionary: You strike approximately in the middle and decide whether you have to search further forward or further backwards.
Why it matters in practice
Basic algorithm for efficient search in sorted data structures. It also illustrates the difference between linear and logarithmic scaling.
Example from business
Example scenario: A sorted list of millions of numerical IDs searches for a value without a complete run through the list.
Limits and pitfalls
- Apply to unsorted data; use off-by-one errors at limits; use inappropriate data structure with slow instant access; confuse O(log n) with constant runtime.
Origin & history
The NIST dictionary describes binary search as repeatedly halving a sorted search area.
Use in mid-sized companies
- Use large sorted data sets and direct index access; in databases, index structures usually take over the practical search optimization.
Frequently asked questions
Do the data have to be sorted?
For classic binary search yes.
How does it scale?
Typically O(log n).
Is it always faster than linear search?
Not for every small input and data structure.
Sources
- binary search · NIST Dictionary of Algorithms and Data Structures, binary search
Source check: 09.10.2026. Definition and documented classification verified; examples describe possible applications.
Editorially reviewed on: