Heap sort is an in-place algorithm that sorts the list with heap. It first changes a list to the heap and then keeps poping it and push the maximum value to the end of the list. To change a list to the heap in-place, list is assumed to be form of complete binary tree. With this assumption, it read from bottom to up and downHeap to change complete binary tree to heap. This takes $O(n log n)$(Infact, it is known to be $O(n)$ with carefull analysis). After that, just pop head and push it to end of the list. As a result, it is $O(n log n)$ in-place sorting algorithm.
1 |
|