What is Binary Search

Pattern overview

binary search (halving search space each step) repeatedly halves a sorted search space by comparing the middle element to the target. You use it when the search space has monotonic properties. You reduce O(n)O(n) linear search to O(log⁡n)O(\log n) by eliminating half the search space each step.

You'll see this in sorted arrays, answer-space searches, and boundary finding. If you can explain these concepts in your own words, you'll solve related problems faster under interview pressure.

1770079291590-lj84r3cpnk.jpg