Question: For your reference only, here is a code for mergesort. public class MergeSort { private static void merge ( Comparable [ ] a , Comparable
For your reference only, here is a code for mergesort.
public class MergeSort
private static void mergeComparable a Comparable aux, int lo int mid, int hi
for int k lo; k hi; k auxk ak;
int i lo j mid;
for int k lo; k hi; k
if i mid ak auxj;
else if j hi ak auxi;
else if lessauxj auxi ak auxj;
else ak auxi;
private static void sortComparable a Comparable aux, int lo int hi
if hi lo return;
int mid lo hi lo;
sorta aux, lo mid;
sorta aux, mid hi;
mergea aux, lo mid, hi;
array inspected here
public static void sortComparable a
Comparable aux new Comparablealength;
sorta aux, alength ;
The input array is:
At the end of a certain recursive call of method sort line with the array looks like this:
How many calls to method merge have been completed?
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
