mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2026-02-02 18:39:09 +08:00
更新图片链接
This commit is contained in:
6
problems/二叉树的迭代遍历.md
Normal file → Executable file
6
problems/二叉树的迭代遍历.md
Normal file → Executable file
@@ -38,7 +38,7 @@
|
||||
|
||||
动画如下:
|
||||
|
||||

|
||||

|
||||
|
||||
不难写出如下代码: (**注意代码中空节点不入栈**)
|
||||
|
||||
@@ -85,7 +85,7 @@ public:
|
||||
|
||||
动画如下:
|
||||
|
||||

|
||||

|
||||
|
||||
**中序遍历,可以写出如下代码:**
|
||||
|
||||
@@ -117,7 +117,7 @@ public:
|
||||
|
||||
再来看后序遍历,先序遍历是中左右,后序遍历是左右中,那么我们只需要调整一下先序遍历的代码顺序,就变成中右左的遍历顺序,然后在反转result数组,输出的结果顺序就是左右中了,如下图:
|
||||
|
||||

|
||||

|
||||
|
||||
**所以后序遍历只需要前序遍历的代码稍作修改就可以了,代码如下:**
|
||||
|
||||
|
||||
Reference in New Issue
Block a user