AI engineering glossary · Data structures algorithms

What is binary search?

Binary search: A method of finding a value in a sorted array by comparing with the middle item and discarding the half that cannot contain it, repeating until found. It takes O(log n) time instead of O(n).

Level: beginnerTopic: Data structures algorithms

Binary search: an example

Looking for 47 among 1,00,000 sorted IDs takes at most about 17 comparisons, since each step halves the range.

Related terms

More Data structures algorithms terms

Where you learn it

Binary search is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.