Heap Sort - rFronteddu/general_wiki GitHub Wiki
O(n log n)
- buildMaxHeap, max will then be in A[1], exchange it to A[n]
- We can remove n by decreasing size by 1
- Heapify and exchange root
- repeat
heapSort(A) {
buildMaxHeap(A);
for i = A.len to 2:
swap (A, i, 1)
A.size--;
maxHeapify(A, 1)
}