next up previous
Next: Up: Previous:

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)

Click on mouse to advance to next frame.





HeapSort



Compare sorting algorithms


next up previous
Next: Up: Previous: