PRACTICE / UNDERSTAND / REPEAT

Data Structures & Algorithms: Binary search

Practice binary search with self-contained questions. Check your answer, then use the explanation to understand the reasoning.

20 questionsAnswers explainedFree · no login
Question 1 of 20
Binary search · MCQQuestion link ↗

Binary search uses inclusive bounds low = 1 and high = 9. Using low + floor((high - low) / 2), what is mid?

Choose one answer
Answer & explanation

Answer: 5

The difference is eight, so the midpoint is four positions above low.