Linear Search & Binary Search · Section 4.3 Algorithms
| Step | Index | Value | Result |
|---|---|---|---|
| 1 | 0 | 4 | 4 ≠ 9 |
| 2 | 1 | 7 | 7 ≠ 9 |
| 3 | 2 | 2 | 2 ≠ 9 |
| 4 | 3 | 9 | 9 = 9 FOUND at index 3 |
| Step | low | high | mid | arr[mid] | Action |
|---|---|---|---|---|---|
| 1 | 0 | 7 | 3 | 7 | 7<11 → low=4 |
| 2 | 4 | 7 | 5 | 11 | 11=11 FOUND |
| n (list size) | Linear: max steps | Binary: max steps |
|---|---|---|
| 10 | 10 | 4 |
| 100 | 100 | 7 |
| 1,000 | 1,000 | 10 |
| 1,000,000 | 1,000,000 | 20 |