Exercise

Implementing binary search

In this video, you learned how to implement linear search and binary search and saw the differences between them.

In this exercise, you need to implement the binary_search() function. Can you do it?

Instructions

100 XP
  • Check whether the search value equals the value in the middle.
  • Check whether the search value is smaller than the value in the middle
  • Set last to the value of middle minus one.