Watch Linear Knight and Binary Ninja compete to find the target!
Binary Search works only on sorted arrays but is incredibly efficient because it eliminates half the search space with each comparison.
| Array Size (N) | Linear Search (N) | Binary Search (log₂ N) |
|---|---|---|
| 16 | 16 steps | 4 steps |
| 1,000 | 1,000 steps | 10 steps |
| 1,000,000 | 1,000,000 steps | 20 steps |
| 1 billion | 1,000,000,000 steps | 30 steps |
Key insight: Linear search checks every element; Binary search halves the problem each step!