next up previous
Next: Analysis Up: CSE 2320: Algorithms and Previous: Recursive Analysis

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.





Copyright © 1998 The University of Texas at Arlington