Binary search is an essential search algorithm that takes in a sorted array and returns the index of the value we are searching for

Do this with the following steps:


  1. Find the midpoint of the sorted array.
  2. Compare the midpoint to the value of interest.
  3. If the midpoint is larger than the value, perform binary search on right half of the array.
  4. If the midpoint is smaller than the value, perform binary search on left half of the array.
  5. Repeat these steps until the midpoint value is equal to the value of interest or we know the value is not in the array.


Comments