#include <stdio.h>voidFix (intA[],intindex);intMain () {intarray[Ten] = {1,3,6,4, +, -,Ten,3,8,2 }; Fix (Array,9); for(inti =9; I >=0; i--){ inttemp =Array[i]; Array[i]= array[0]; array[0] =temp; Fix (Array, I-1); } for(inti =0; I <Ten; i++) {printf ("%d", Array[i]); }}voidFix (intA[],intindex) { for(inti = index; I >=0; i--){ intParent = (I-1) /2; if(Parent >=0){ if(A[i] >A[parent]) { inttemp =A[i]; A[i]=A[parent]; A[parent]=temp; } } }}
Heap Sort
Http://www.cnblogs.com/mengdd/archive/2012/11/30/2796845.html
#include <stdio.h>voidMerge (intA[],intFirstintend);voidSort (intA[],intFirstintMidintend);inttemp[Ten];intMain () {intarray[Ten] = {1,3,6,4, +, -,Ten,3,8,2 }; Merge (Array,0,9); for(inti =0; I <Ten; i++) {printf ("%d", Array[i]); } getchar ();}voidMerge (intA[],intFirstintend) { intMid = (first + end)/2; if(Mid! =First ) Merge (A, first, mid); if(Mid! =end) Merge (A, Mid+1, end); Sort (A, first, mid, end);}voidSort (intA[],intFirstintMidintend) { inti = First, J = mid +1, k =0; while(I <= Mid | | J <=end) { if(A[i] >A[j]) { if(J >end) {Temp[k+ +] = a[i++]; } Else{temp[k+ +] = a[j++]; } } Else{ if(I >mid) {Temp[k]= a[j++]; } Else{temp[k+ +] = a[i++]; } } } for(inti =0; I < K; i++) {A[first+ i] =Temp[i]; }}
Merge sort
Http://www.cnblogs.com/Braveliu/archive/2013/01/14/2860456.html
Http://baike.baidu.com/link?url=ppHPIR22RnpSQO0AHPAfTFHGdm5Hk7yaM_JM5L3o_nYK8nmBwWL0dDTxrzA4ZZhNJjVYHIBpKaq-FlmPmzypQa
"Interview preparation" sorting algorithm heap,