This commit is contained in:
krahets
2023-09-21 20:44:38 +08:00
parent fca420d938
commit 02757deee2
13 changed files with 408 additions and 623 deletions
-1
View File
@@ -1151,7 +1151,6 @@ comments: true
while (true) {
// 判断节点 i, l, r 中值最大的节点,记为 ma
int l = left(i), r = right(i), ma = i;
// 若节点 i 最大或索引 l, r 越界,则无须继续堆化,跳出
if (l < size() && maxHeap[l] > maxHeap[ma])
ma = l;
if (r < size() && maxHeap[r] > maxHeap[ma])