Binary Search
Also known as: bisection search, half-interval search
An efficient algorithm for finding a target value in a sorted list by repeatedly halving the search range. Binary search is orders of magnitude faster than linear search for large sorted datasets.
๐ก Intuition
Looking up a word in a dictionary: open to the middle, then go left or right depending on where your word falls.
Core Idea
Each comparison eliminates half the remaining possibilities โ O(log n) vs O(n) for linear search.
๐ฌ Example
๐ฏ Why It Matters
Binary search is orders of magnitude faster than linear search for large sorted datasets.
โ ๏ธ Common Confusion
Binary search only works on sorted data โ applying it to unsorted data gives wrong results.
Related Concepts
Prerequisites
Next Steps
How Binary Search Connects to Other Ideas
To understand binary search, you should first be comfortable with searching, array and efficiency. Once you have a solid grasp of binary search, you can move on to linear search.
Go Deeper
Frequently Asked Questions
What is Binary Search in CS Thinking?
An efficient algorithm for finding a target value in a sorted list by repeatedly halving the search range.
Why is Binary Search important?
Binary search is orders of magnitude faster than linear search for large sorted datasets.
What do students usually get wrong about Binary Search?
Binary search only works on sorted data โ applying it to unsorted data gives wrong results.
What should I learn before Binary Search?
Before studying Binary Search, you should understand: searching, array, efficiency.