mirror of
https://github.com/krahets/hello-algo.git
synced 2026-08-19 23:10:58 +00:00
Polish the chapter
introduction, computational complexity.
This commit is contained in:
@@ -69,7 +69,7 @@ class MaxHeap {
|
||||
while true {
|
||||
// 获取节点 i 的父节点
|
||||
let p = parent(i: i)
|
||||
// 当“越过根节点”或“节点无需修复”时,结束堆化
|
||||
// 当“越过根节点”或“节点无须修复”时,结束堆化
|
||||
if p < 0 || maxHeap[i] <= maxHeap[p] {
|
||||
break
|
||||
}
|
||||
@@ -110,7 +110,7 @@ class MaxHeap {
|
||||
if r < size(), maxHeap[r] > maxHeap[ma] {
|
||||
ma = r
|
||||
}
|
||||
// 若节点 i 最大或索引 l, r 越界,则无需继续堆化,跳出
|
||||
// 若节点 i 最大或索引 l, r 越界,则无须继续堆化,跳出
|
||||
if ma == i {
|
||||
break
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user