next up previous
Next: Up: Previous:

BuildHeap



BuildHeap(A)
1
$\;\;\;\;\;$HeapSize(A) = length(A)
2
$\;\;\;\;\;$for i = $\lfloor$ length(A)/2 $\rfloor$ downto 1
3
$\;\;\;\;\;$ $\;\;\;\;\;$Heapify(A,i)



A[($\lfloor$ n/2 $\rfloor$ + 1) ... n] are leaves and heaps.

Click on mouse to advance to next frame.




next up previous
Next: Up: Previous: