Skills101
← Tech dictionary

Data structures & algorithms

What is Binary search?

Binary search finds a target in a sorted array by comparing it with the middle element and discarding the half that cannot contain it. It runs in O(log n) time.

Example

Searching 1,000,000 sorted roll numbers takes at most about 20 comparisons.

Learn it properlyDSA tutorials — free, with diagrams, quizzes and a certificate

Related terms