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, 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
Get step-by-step solutions from verified subject matter experts
