Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

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

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... blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Building Java Programs A Back To Basics Approach

Authors: Stuart Reges, Marty Stepp

5th Edition

9780135471944

Students also viewed these Programming questions