diff --git a/docs/chapter_tree/binary_tree_traversal.assets/preorder_step1.png b/docs/chapter_tree/binary_tree_traversal.assets/preorder_step1.png new file mode 100644 index 000000000..a94f9a13a Binary files /dev/null and b/docs/chapter_tree/binary_tree_traversal.assets/preorder_step1.png differ diff --git a/docs/chapter_tree/binary_tree_traversal.assets/preorder_step10.png b/docs/chapter_tree/binary_tree_traversal.assets/preorder_step10.png new file mode 100644 index 000000000..79f991fbc Binary files /dev/null and b/docs/chapter_tree/binary_tree_traversal.assets/preorder_step10.png differ diff --git a/docs/chapter_tree/binary_tree_traversal.assets/preorder_step11.png b/docs/chapter_tree/binary_tree_traversal.assets/preorder_step11.png new file mode 100644 index 000000000..cd12146e9 Binary files /dev/null and b/docs/chapter_tree/binary_tree_traversal.assets/preorder_step11.png differ diff --git a/docs/chapter_tree/binary_tree_traversal.assets/preorder_step2.png b/docs/chapter_tree/binary_tree_traversal.assets/preorder_step2.png new file mode 100644 index 000000000..b2e81599a Binary files /dev/null and b/docs/chapter_tree/binary_tree_traversal.assets/preorder_step2.png differ diff --git a/docs/chapter_tree/binary_tree_traversal.assets/preorder_step3.png b/docs/chapter_tree/binary_tree_traversal.assets/preorder_step3.png new file mode 100644 index 000000000..9fef26c92 Binary files /dev/null and b/docs/chapter_tree/binary_tree_traversal.assets/preorder_step3.png differ diff --git a/docs/chapter_tree/binary_tree_traversal.assets/preorder_step4.png b/docs/chapter_tree/binary_tree_traversal.assets/preorder_step4.png new file mode 100644 index 000000000..e947bb306 Binary files /dev/null and b/docs/chapter_tree/binary_tree_traversal.assets/preorder_step4.png differ diff --git a/docs/chapter_tree/binary_tree_traversal.assets/preorder_step5.png b/docs/chapter_tree/binary_tree_traversal.assets/preorder_step5.png new file mode 100644 index 000000000..30e1fdfbe Binary files /dev/null and b/docs/chapter_tree/binary_tree_traversal.assets/preorder_step5.png differ diff --git a/docs/chapter_tree/binary_tree_traversal.assets/preorder_step6.png b/docs/chapter_tree/binary_tree_traversal.assets/preorder_step6.png new file mode 100644 index 000000000..ed02b8128 Binary files /dev/null and b/docs/chapter_tree/binary_tree_traversal.assets/preorder_step6.png differ diff --git a/docs/chapter_tree/binary_tree_traversal.assets/preorder_step7.png b/docs/chapter_tree/binary_tree_traversal.assets/preorder_step7.png new file mode 100644 index 000000000..92a026521 Binary files /dev/null and b/docs/chapter_tree/binary_tree_traversal.assets/preorder_step7.png differ diff --git a/docs/chapter_tree/binary_tree_traversal.assets/preorder_step8.png b/docs/chapter_tree/binary_tree_traversal.assets/preorder_step8.png new file mode 100644 index 000000000..895638e6b Binary files /dev/null and b/docs/chapter_tree/binary_tree_traversal.assets/preorder_step8.png differ diff --git a/docs/chapter_tree/binary_tree_traversal.assets/preorder_step9.png b/docs/chapter_tree/binary_tree_traversal.assets/preorder_step9.png new file mode 100644 index 000000000..0b302f394 Binary files /dev/null and b/docs/chapter_tree/binary_tree_traversal.assets/preorder_step9.png differ diff --git a/docs/chapter_tree/binary_tree_traversal.md b/docs/chapter_tree/binary_tree_traversal.md index b3f9c6497..9b7d82b5a 100755 --- a/docs/chapter_tree/binary_tree_traversal.md +++ b/docs/chapter_tree/binary_tree_traversal.md @@ -204,7 +204,42 @@ !!! note - 使用循环一样可以实现前、中、后序遍历,但代码相对繁琐,有兴趣的同学可以自行实现。 + 我们也可以仅基于循环实现前、中、后序遍历,有兴趣的同学可以自行实现。 + +递归过程可分为“递”和“归”两个相反的部分。“递”表示开启新方法,程序在此过程中访问下一个节点;“归”表示函数返回,代表该节点已经访问完毕。如下图所示,为前序遍历二叉树的递归过程。 + +=== "<1>" + ![preorder_step1](binary_tree_traversal.assets/preorder_step1.png) + +=== "<2>" + ![preorder_step2](binary_tree_traversal.assets/preorder_step2.png) + +=== "<3>" + ![preorder_step3](binary_tree_traversal.assets/preorder_step3.png) + +=== "<4>" + ![preorder_step4](binary_tree_traversal.assets/preorder_step4.png) + +=== "<5>" + ![preorder_step5](binary_tree_traversal.assets/preorder_step5.png) + +=== "<6>" + ![preorder_step6](binary_tree_traversal.assets/preorder_step6.png) + +=== "<7>" + ![preorder_step7](binary_tree_traversal.assets/preorder_step7.png) + +=== "<8>" + ![preorder_step8](binary_tree_traversal.assets/preorder_step8.png) + +=== "<9>" + ![preorder_step9](binary_tree_traversal.assets/preorder_step9.png) + +=== "<10>" + ![preorder_step10](binary_tree_traversal.assets/preorder_step10.png) + +=== "<11>" + ![preorder_step11](binary_tree_traversal.assets/preorder_step11.png) ### 复杂度分析