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