next up previous
Next: Pseudocode Up: CSE 2320: Algorithms and Previous: Exercise 7.1-2

Maintaining the Heap Property



Heapify(A,i)



\psfig{figure=figures/f3-3.ps,width=4in,height=3in}

Notice that if A[left(i)] > A[i] or if A[right(i)] > A[i] or both (take largest) then swap and recurse until recursion bottoms out at bottom of heap.



Copyright © 1998 The University of Texas at Arlington