Question: 6. Given the following Java code for a binary search algorithm, answer each question: boolean binarySearch( int [] values, int target, int low, int high

 6. Given the following Java code for a binary search algorithm,

6. Given the following Java code for a binary search algorithm, answer each question: boolean binarySearch( int [] values, int target, int low, int high )1 int midpoint - (first last) >> 1; if( low > high ) return false; if ( target -values [midpoint] ) return true; else if( target > values [midpoint] ) return binarySearch(values, target, midpoint + 1, high); return binarySearch (values, target, low, midpoint - 1); (a) (2 points) What is the best case complexity when searching for a single target item in values? Answer (2 points) (b) (2 points) What is the worst case complexity when searching for a single target item in values! Answer (2 points) (c) (3 points) What is the worst case complexity when searching for n target items in values! Answer (2 points)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!