Question: Suppose we are calling (binarySearch(numbers, 45) on a sorted array called numbers initialized as follows: // index 0 1 2 3 4 5 6
Suppose we are calling (binarySearch(numbers, 45) on a sorted array called numbers initialized as follows: // index 0 1 2 3 4 5 6 7 8 int[] numbers {-5, -3, 0, 2, 8, 15, 22, 38, 45}; // search for the value 45 int index binarySearch(numbers, 45); = = Write the indexes of the elements that would be examined by the binary search (the mid values in our algorithm's code). Assume that we are using the binary search algorithm shown on page 852. Write your answers separated by one space. E.g. binarySearch (8) would be "4"
Step by Step Solution
There are 3 Steps involved in it
The binary search algorithm works by repeatedly dividing the search space in half until ... View full answer
Get step-by-step solutions from verified subject matter experts
