参照下图的方法,说明MAX-HEAPIFY(A,3)在数组A=<27,17,3,16,13,10,1,5,7,12,4,8,9,0>上的操作过程。
Max_Heapify(A,idx,max) left = 2*idx right = 2*idx if(left<max and A[left]>A[idx]) then largest = left else largest = idx if(right < max and A[right]>A[largest]) then largest = ritht if(largest != idx) then exchange A[largest] with A[idx] Max_Heapify(A,largest,max) end