Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please answer and explanation all parts of this problem. Thank you! 6. Given the

ID: 3753905 • Letter: P

Question

Please answer and explanation all parts of this problem. Thank you!

6. Given the following Java code for a binary search algorithm, answer each question: boolean binarySearch( int values, int target, int low, int high ) int midpoint = (first + last) >> 1; if low high) return false; if ( targetvalues [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 2 target items in values? Answer (2 points):

Explanation / Answer

First note that to use binary search on a collection, the collection must first be sorted first.

Answers :

Explanation