Skip to content

Commit 6ca34be

Browse files
authored
Update binary-tree-traversal.md
1 parent 404953b commit 6ca34be

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

thinkings/binary-tree-traversal.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ BFS 的关键点在于如何记录每一层次是否遍历完成, 我们可以
103103

104104
## 双色标记法
105105

106-
我们直到垃圾回收算法中,有一种算法叫三色标记法。 即:
106+
我们知道垃圾回收算法中,有一种算法叫三色标记法。 即:
107107

108108
- 用白色表示尚未访问
109109
- 灰色表示尚未完全访问子节点
@@ -137,7 +137,7 @@ class Solution:
137137
return res
138138
```
139139

140-
如要实现前序、后序遍历,只需要调整左右子节点的入栈顺序即可。
140+
如要实现前序、后序遍历,只需要调整左右子节点的入栈顺序即可。可以看出使用三色标记法, 其写法类似递归的形式,因此便于记忆和书写,缺点是使用了额外的内存空间。不过这个额外的空间是线性的,影响倒是不大。
141141

142142
## Morris 遍历
143143

0 commit comments

Comments
 (0)