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.
*/
package assignment.task1;

/*
* 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.
*
* @param input array a needs to be sorted.
*/
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
int n = a.length;
if(n<2){//终止条件 return; } int mid = n/2; L = new int[mid]; R = new int[n-mid]; for(int i=0;i