Where an unsuccessful binary search ends

A sorted list holds 12 values at positions 0 through 11: 4, 9, 13, 18, 22, 27, 31, 36, 40, 45, 51 and 58. You run a standard binary search for the value 33. It starts with low = 0 and high = 11, uses mid = (low + high) // 2 with integer division rounding down, sets low = mid + 1 when the probed value is smaller than 33, and sets high = mid − 1 when it is larger. The loop runs while low is less than or equal to high.


Give each answer as a whole number: the number of probes made before the search stops, the final value of low, the final value of high, and the value currently stored at the position given by the final low.

Your answers

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Binary Search Questions: