package sort;
/**
* Created by ozc on 2018/3/19.
*
* @author ozc
* @version 1.0
*/
public class MergeSort {
public static void main(String[] args) {
/*int[] arrays = {9, 2, 5, 1, 3, 2, 9, 5, 2, 1, 8};
sort.MergeSort(arrays, 0, arrays.length - 1);
System.out.println("Java3y" + arrays);*/
System.out.println("Hello World");
}
/**
*
*
* @param arrays
* @param L
* @param R
*/
public static void mergeSort(int[] arrays, int L, int R) {
//
if (L == R) {
return;
} else {
//
int M = (L + R) / 2;
//
mergeSort(arrays, L, M);
//
mergeSort(arrays, M + 1, R);
//
merge(arrays, L, M + 1, R);
}
}
/**
*
*
* @param arrays
* @param L
* @param M
* @param R
*/
public static void merge(int[] arrays, int L, int M, int R) {
//
int[] leftArray = new int[M - L];
//
int[] rightArray = new int[R - M + 1];
//
for (int i = L; i < M; i++) {
leftArray[i - L] = arrays[i];
}
for (int i = M; i