Skip to main contentSkip to solution

Consider the sorted list of 15 elements:-

list = [2, 3, 5, 7, 10, 11, 12, 17, 19, 23, 29, 31, 37, 41, 43]

We need to search for element 2 in this list. What will be the order of the elements found at MID position in the first four iterations of binary search?

(A) 2

(B) 3

(C) 17

(D) 7

Solution

✅ Correct Option: 4

Binary search uses mid=⌊low+high2⌋mid = \left\lfloor \dfrac{low + high}{2} \right\rfloor with indices 0 to 14. Since the target 2 is smaller than the middle element, the search keeps moving to the left half by setting high=mid−1high = mid - 1.

IterationlowhighmidElement at midComparison with 2
1014717 (C)2 < 17, go left
20637 (D)2 < 7, go left
30213 (B)2 < 3, go left
40002 (A)found

The order of mid elements is 17, 7, 3, 2, which is (C), (D), (B), (A).

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question