Introduction
Binary search is a fast algorithm for finding a target value in a sorted array. Instead of checking every element like linear search at , you repeatedly split the search space in half.
Here's the key insight: if the array is sorted, one comparison tells you which half contains your target. You eliminate of remaining elements each step.
This halving gives you time complexity. For an array of million elements, you need at most comparisons instead of million.