Consider a following sorted numList comprising 9 elements:
numList = [10,11,12,17,19,23,29,31,37]
How many iterations will occur to search for element "29" using a binary search technique?
Consider a following sorted numList comprising 9 elements:
numList = [10,11,12,17,19,23,29,31,37]
How many iterations will occur to search for element "29" using a binary search technique?
Solution
✅ Correct Option: 2
Binary search compares the target with the middle element and discards the half that cannot contain it. Here , with indices 0 to 8.
| Iteration | low | high | mid | numList[mid] | Result |
|---|---|---|---|---|---|
| 1 | 0 | 8 | 4 | 19 | , so search the right half (low = 5) |
| 2 | 5 | 8 | 6 | 29 | Found |
The element 29 is found in iterations.
Related questions:
2026: 23 May Shift 2
2026: 13 May Shift 2
2026: 19 May Shift 1
2026: 11 May Shift 2
2026: 23 May Shift 2