Consider a list [-10, -4 ,3 ,5, 6, 8, 9]. How many comparisons will be required if binary search is applied to find the element '9'?
Consider a list [-10, -4 ,3 ,5, 6, 8, 9]. How many comparisons will be required if binary search is applied to find the element '9'?
Solution
✅ Correct Option: 2
Binary search compares the target with the middle element and discards the half that cannot contain it. The list has 7 elements at positions 0 to 6.
| Comparison | low | high | mid | Element at mid | Result |
|---|---|---|---|---|---|
| 1 | 0 | 6 | 3 | 5 | , search right half |
| 2 | 4 | 6 | 5 | 8 | , search right half |
| 3 | 6 | 6 | 6 | 9 | found |
Total comparisons
Option 3: 7 is the count for linear search, which checks 9 as the last element.
Related questions:
2026: 11 May Shift 2
2026: 11 May Shift 2
2026: 29 May Shift 2
2026: 23 May Shift 2