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).
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
- Binary search tree
- Binary tree
- Bipartite graph
- Bloom filter
- Breadth-first search
- Bubble sort
- Call stack
- Circular buffer
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.