Question: public class BinarySearch { public static int binarySearch ( Object [ ] data, Object key ) { int lower = 0 ; int upper =

public class BinarySearch {
public static int binarySearch(Object [] data, Object key){
int lower =0;
int upper = data.length -1;
int location;
while (true){
location = midpoint(lower, upper);
if (data[location]== key){ return (location); }
else if (data[location]< key){ lower = location +1; } else { upper = location -1; }
}}
public static int midpoint(int lower, int upper){ return ((lower + upper)/2); }
}
A control flow graph representation.

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 Programming Questions!