java 归并排序

归并排序,体现“分治法”的思想
import java.util.Arrays;

public class MergeSort {
public static void main(String[] args) {
	int [] a ={1,5,6,2,3,4,7,9,8};
	mergeSort(a,0,a.length-1);
	System.out.println("归并排序结果="+Arrays.toString(a));
}

private static void mergeSort(int[] a, int i, int j) {
	// TODO Auto-generated method stub
	int mid =(i+j)/2;
	if(i

你可能感兴趣的:(基础算法--合格码农)