Exercise

Binary search using recursion

In this exercise, you will implement the binary search algorithm you just learned using recursion. Recall that a recursive function refers to a function calling itself.

Instructions

100 XP
  • Define the base case.
  • Check whether the search value equals the value in the middle.
  • Call the binary_search_recursive() function recursively on the left half of the list.
  • Call the binary_search_recursive() function recursively on the right half of the list.