🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← All topics

Binary Search Quiz: questions with answers

8 questions, each with the answer and a short explanation.

Take the timed quiz + get a certificate →
  1. Q1. About how many comparisons does binary search need on 1,000,000 sorted numbers?
  2. Q2. Why is mid = lo + (hi - lo) / 2 preferred over (lo + hi) / 2 in Java?
  3. Q3. What does this return for nums = [1, 3, 5, 7], target = 4? (code)
  4. Q4. Which statements about binary search are true? (select all that apply)
  5. Q5. In a rotated sorted array like [4, 5, 6, 7, 0, 1, 2], what is always true at any mid?
  6. Q6. "Binary search on the answer" works when…
  7. Q7. Koko eats piles [3, 6, 7, 11] and has h = 8 hours. What is the minimum speed k?
  8. Q8. Which loop pairing can cause an infinite loop?