void swap(int * a,int * b){ int temp = *a; *a = *b; *b = temp;}void PercDown(int * array,int p,int N){ int child,parent; int x = array[p]; for (parent = p; (parent*2+1)=0; --i) {//创建堆 PercDown(array,i,N); } for (i = N-1; i>0 ; --i) { swap(&array[0], &array[i]); PercDown(array, 0, i); }}
参考:网易云课堂:浙江大学-数据结构-陈越、何钦铭
posted on 2018-03-03 15:40 阅读( ...) 评论( ...)