Binary Search — step-by-step
Core rule: Binary search works only on a sorted array. Each step cuts the search space in half.
Mental model
Keep two pointers: low and high. Check the middle. Move left or right depending on the key.
Common mistakes
- Wrong loop condition (use low <= high).
- Not updating low/high correctly.
- Doing binary search on unsorted data.