Merge Sort Quiz

Last updated over 1 year ago
4 questions
public void sort( int[] list, int front, int back)
{
int mid = (front+back)/2;
if( < blank 1 > ) return;
sort(list, front, mid);
sort(list, mid, back);
help(list, front, back);
}
private void help( int[] stuff, int front, int back)
{
int diff = back-front;
int[] temp = new int[ dif ];
int beg = front, mid = (front+back)/2;
int saveMid = mid;
int spot = 0;
while( beg<saveMid && mid<back ) {
if(stuff[ beg ] < stuff[ mid ] )
temp[ spot++ ]= stuff[ beg++ ];
else
temp[ spot++ ]= stuff[ mid++ ];
}
while( beg < saveMid )
temp[ spot++ ]= stuff[ beg++ ];
while( mid < back )
temp[ spot++ ]= stuff[ mid++ ];
for(int i = 0; i < < blank 2 > ; ++i)
stuff[front+i]=temp[i];
}
//code in the main
sort(list, 0, list.length);
1

Which of the following code statements would correctly fill < blank 1 > ?

1

Which of the following code statements would correctly fill < blank 2 > ?

1

Use the array below and the code to the right
for the next question.
list = {3,15,61,11,7,9,2};

What would be the value of list after four passes of the help() method?

1

Use the array below and the code to the right
for the next question.
How many times would help() be called before list was sorted?