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
5.00 Ratings (1 Votes)
There are 3 Steps involved in it
Step: 1
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...Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started