OSDN Git Service
(root)
/
oi-wiki
/
main.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
67135f2
)
Update binary-heap.md
author
Asurx
<9735627709@qq.com>
Wed, 4 Sep 2019 03:00:46 +0000
(11:00 +0800)
committer
GitHub
<noreply@github.com>
Wed, 4 Sep 2019 03:00:46 +0000
(11:00 +0800)
将二叉堆上移、下移代码中的下移代码修正为大根堆对应代码
docs/ds/binary-heap.md
patch
|
blob
|
history
diff --git
a/docs/ds/binary-heap.md
b/docs/ds/binary-heap.md
index
cc6e612
..
6c2c712
100644
(file)
--- a/
docs/ds/binary-heap.md
+++ b/
docs/ds/binary-heap.md
@@
-62,8
+62,8
@@
up(x) {
down(x) {
while (x * 2 <= n) {
t = x * 2;
- if (t + 1 <= n && h[t + 1]
<
h[t]) t++;
- if (h[t]
>
= h[x]) break;
+ if (t + 1 <= n && h[t + 1]
>
h[t]) t++;
+ if (h[t]
<
= h[x]) break;
swap(h[x], h[t]);
x = t;
}