//建立大根堆的过程---------------->时间复杂度:log1+log2+...+logN-1==O(N)
public static void heapSort(int[] a) {
if (a == null || a.length < 2) {
return;
}
for (int i = 0; i < a.length; i++) {
heapInsert(a, i); //每次都调整大根堆
}
}
//调整的过程
public static void heapInsert(int[] a, int index) {
while (a[index] > a[(index - 1) / 2]) { //此结点大于它的父节点,进行交换
swap(a, index