Please ask
import java.util.Arrays;
/ *
- 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];
}
}
}