Question: Given the following binary search code. Please show what will be printed by the program on the screen if the function is called as
Given the following binary search code. Please show what will be printed by the program on the screen if the function is called as follows: int[] numbers (8, 15, 22, 29, 36, 54, 55, 61, 70, 73, 88); int target= 29; binarySearch (numbers, 0, numbers.length-1, target); public static boolean binarySearch (int[] data, int min, int max, int target) { boolean found = false; int midpoint = (min + max)/ 2; // determine the midpoint System.out.println (midpoint + ":" + data [midpoint]); if (data [midpoint] =target) ( found true; } else if (target < data [midpoint]) System.out.println (target + " " + data [midpoint]); if (max >= midpoint + 1) { // search in the right half of array found= binarySearch(data, midpoint + 1, max, target); } return found; Given the following binary search code. Please show what will be printed by the program on the screen if the function is called as follows: int[] numbers (8, 15, 22, 29, 36, 54, 55, 61, 70, 73, 88); int target= 29; binarySearch (numbers, 0, numbers.length-1, target); public static boolean binarySearch (int[] data, int min, int max, int target) { boolean found = false; int midpoint = (min + max)/2; // determine the midpoint System.out.println (midpoint + ":" + data [midpoint]); if (data [midpoint] =target) ( found true; } else if (target < data [midpoint]) System.out.println (target + " " + data [midpoint]); if (max >= midpoint + 1) { // search in the right half of array found= binarySearch(data, midpoint + 1, max, target); } return found;
Step by Step Solution
3.38 Rating (148 Votes )
There are 3 Steps involved in it
Lets analyze the provided binary search code and determine the output when the function is called with the given parameters Java int numbers 8 15 22 29 36 54 55 61 70 73 88 int target 29 binarySearchn... View full answer
Get step-by-step solutions from verified subject matter experts
