3.3.3 - Heap Sort
1. 演算法
將{5, 3, 2, 1, 7, 8, 9, 10}
將資料以Bottom-Up方式建立Max-Heap
執行Delete-Max
SWAP(Root, the last node)
刪除最大值
將剩下的Heap調整為Max-Heap

output=10

output=9

2. 性質
Time Complexity:
以Bottom-Up建立Heap共花
執行Delete-Max,每一回合共花 ,共有n回合
Space Complexity:
Heap sorting is a unstable sorting method.
Last updated