Using Java to implement a recursive sorting may not be successful due to the change of values. Have you been debug for a long time or haven't found out what the problem is?

Please ask
import java.util.Arrays;

if you have a question.

/ *

  • Recursive implementation of merge sorting

* /
public class MergeSort {

public static void main(String args[]){
    int a[] = {0,4,23,1,5,76,34,2,13,79};
    mergeSort(a,0,a.length-1);
}

// arr[l...r]
private static void mergeSort(int arr[],int l,int r) {

    if (l < r) {//
        int mid = (l + r) / 2;
        mergeSort(arr,l,mid);//
        mergeSort(arr,mid+1,r);//
        __merge(arr, l, mid, r);//lmidr

        //System.out.println(Arrays.toString(arr));
    }
}
private static void __merge(int arr[],int l,int mid,int r){

    int aux[] = Arrays.copyOfRange(arr,l,r+1);
    System.out.println(Arrays.toString(aux));
    int i = l,j = mid;//,il;jmid+1
    int k = 0;//
    while(i<=mid&&j<=r){
        if(aux[i]<aux[j]){
            arr[kPP] = aux[iPP];
        } else if (aux[i]>aux[j]){
            arr[kPP] = aux[jPP];
        }
    }

    //
    while(i<=mid){
        arr[kPP] = aux[iPP];
    }
    //
    while(j<=r){
        arr[kPP] = aux[jPP];
    }

}

}

Apr.01,2021
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e48a57-44cc6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e48a57-44cc6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?