next up previous
Next: Up: Previous:

Heapsort

In-place sort.

Running time: O(n lg n)



Heaps



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



Heap: An array A representing a complete binary tree for HeapSize(A) elements satisfying the heap property:

A[parent(i)] >= A[i]

for every node i except the root node.



Because the array may hold more numbers than are contained in the heap, HeapSize(A) $\leq$ length(A) (heap insertion and deletion)




next up previous
Next: Up: Previous: