Mergesort in java

后端 未结 12 522
予麋鹿
予麋鹿 2020-12-03 06:09

I am new to Java and have tried to implement mergesort in Java. However, even after running the program several times, instead of the desired sorted output, I am getting the

12条回答
  •  独厮守ぢ
    2020-12-03 06:20

    public class MergeSort{
    public static void sort(int[] in){
        if(in.length <2) return; //do not need to sort
        int mid = in.length/2;
        int left[] = new int[mid];
        int right[] = new int[in.length-mid];
        for(int i=0; i

提交回复
热议问题