Merge Sort Work Sheet
By Mickey Arnold
starstarstarstarstar
Last updated 10 months ago
8 Questions
Complete the following method binarySearch. Fill in each blank below.
int binarySearch(int [] stuff, int val )
{
int bot= 0, top = stuff.length-1;
while(bot<=top)
{
int middle = __________________________
if (stuff[middle] == val) return middle;
else
if (stuff[middle] > val)
top = _____________________
else
bot = _____________________
}
return -1;
}
Write the binarySearch using recursion.
public static int binarySearch(int[] stuff, int item, int bot, int top)
{
//Code goes here.
}