Skip to main contentSkip to solution

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 mid=⌊(low+high)/2⌋mid = \lfloor (low + high)/2 \rfloor, with indices 0 to 8.

IterationlowhighmidnumList[mid]Result
10841929>1929 > 19, so search the right half (low = 5)
258629Found

The element 29 is found in 2\boxed{2} iterations.

Keyboard Shortcuts

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