Updating the interval after a probe

A binary search on a sorted list of integers uses mid = (low + high) // 2, where // is integer division that rounds down. Partway through a search, the interval is low = 10 and high = 25.


The next probe position is mid = . The element stored there is greater than the target, so the search keeps only positions below it and sets high = . The probe after that is at position . If the element at position 13 is smaller than the target, the search sets low = .

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: