CS计算机代考程序代写 algorithm /*

/*
* The given code is provided to assist you to complete the required tasks. But the
* given code is often incomplete. You have to read and understand the given code
* carefully, before you can apply the code properly.
*/

/*
* Please review Lecture 5 Algorithms Part I, slide 20 to complete this task.
* */
public class MergeSort {

/**
* Sorts an array [1…n] by divide-and-conquer. It must use merge() method.
*
*/
public static void mergeSort(int[] a) {
/* */
int[] L = null; // This array will store the left half of array
int[] R = null; // This array will store the right half of array
// TODO: Complete this method
// START YOUR CODE
if(a.length<2){ return; } if (a.length >= 2) {
// split array in half
int mid=a.length/2;
L=new int[mid];
R=new int[a.length-mid];
System.arraycopy(a, 0, L, 0, L.length);
System.arraycopy(a, mid, R, 0, R.length);
mergeSort(L);
mergeSort(R);

}

// END YOUR CODE
merge(a,L,R); //Do not modify this part of code.
}

/**
* Merges sorted subarray L and subarray R into sorted array a.
*

*/
public static void merge(int[] a, int[] L, int[] R) {

tracker.calltracking(a,L,R); //Do not modify this method. Otherwise, you will be penalized for violation.
// TODO: Complete this method
// START YOUR CODE
int i=0,j=0,k=0;
while(i