carloscn / carloscn/structstudy
二叉树的层次/前序/中序/后续遍历
- Dominant language
- C
- Stars
- 4
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
### 问题描述
https://leetcode.cn/problems/binary-tree-preorder-traversal/
很多问题可以转换为二叉树的结构,然后在二叉树上面进行查找,排序之类的。因此掌握二叉树的遍历(查找)技巧,是解决这类问题的必经之路。二叉树分为分层、前序、中序、后续四种遍历方法。这个小节我们来使用递归进行二叉树的前序遍历。

二叉树的中序遍历规则是:**左根右**,上图输出: [8 4 9 2 10 5 1 6 3 7]
二叉树的前序遍历规则是:**根左右**,上图输出: [1 2 4 8 9 5 10 3 6 7]
二叉树的后续遍历规则是:**左右根**,上图输出: [8 9 4 10 5 2 6 7 3 1]
二叉树的层次遍历规则是:**自上下**, 上图输出:[1 2 3 4 5 6 7 8 9 10]
**请创建该二叉树,并编写函数打印二叉树的中序、前序、后续和层次遍历结果**。
### 附录I
通过前序遍历和中序遍历还原二叉树:
演算过程如下,通常就是一步步的找到根节点和左右节点。

Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.