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

Heapsort

Heapsort(A)
1
$\;\;\;\;\;$BuildHeap(A)
2
$\;\;\;\;\;$for i = length(A) downto 2
3
$\;\;\;\;\;$ $\;\;\;\;\;$swap(A[1], A[i])
4
$\;\;\;\;\;$ $\;\;\;\;\;$HeapSize(A) = HeapSize(A) - 1
5
$\;\;\;\;\;$ $\;\;\;\;\;$Heapify(A, 1)





HeapSort



Compare sorting algorithms



Copyright © 1998 The University of Texas at Arlington