Skip to main contentSkip to solution

In the given list=[-4, 0, 2, 7, 8, 17, 19]. Determine the number of iterations required to find element 7 using binary search.

Solution

✅ Correct Option: 1

Binary search first checks the middle element. The list has 7 elements at indices 0 to 6.

mid=⌊0+62⌋=3\text{mid} = \left\lfloor \dfrac{0 + 6}{2} \right\rfloor = 3

The element at index 3 is 77, which is the target, so the search ends at the first comparison: 1 iteration\boxed{1 \text{ iteration}}

Keyboard Shortcuts

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