Binary Search is the detective of algorithms. It finds a target number (42) in a sorted list by always asking the middle person.
We start with the whole list (Low=0, High=14). We calculate the Middle: (0 + 14) / 2 = Index 7. VISUAL: The Rose Arrow points to 32.
Is 32 the target (42)? No. Is it smaller or bigger? 32 is SMALLER than 42. This means our target must be to the RIGHT.
Since 32 was too small, everything to its left is also too small. We move Low to Mid + 1 (Index 8). The search space shrinks instantly!
New Range: 8 to 14. Middle is (8 + 14) / 2 = Index 11. The value is 64.
64 is BIGGER than 42. So our target must be to the LEFT. We don't care about anything 64 or higher anymore.
We move High to Mid - 1 (Index 10). Now we only care about Indices 8, 9, and 10. We are closing in!
New Range: 8 to 10. Middle is (8 + 10) / 2 = Index 9. The value is 42.
Is 42 equal to 42? YES! We found it at Index 9. It only took 3 checks. A linear search would have taken 10 checks!
We found it in just 3 steps. Even if we had 1,000,000 items, it would only take about 20 steps! This is the power of O(log n).