Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
御承扬
binary-tree-struct
提交
5dd0f19d
B
binary-tree-struct
项目概览
御承扬
/
binary-tree-struct
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
B
binary-tree-struct
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
5dd0f19d
编写于
5月 20, 2019
作者:
P
pyc-ycy
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
https://github.com/pengyoucongcode/C-code
上级
8651f4fb
423d5e64
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
45 addition
and
0 deletion
+45
-0
README.md
README.md
+45
-0
binary tree.cpp
binary tree.cpp
+0
-0
未找到文件。
README.md
0 → 100644
浏览文件 @
5dd0f19d
# binary-tree-struct
**
Using this program, you can create, traverse the binary tree,
and calculate the number of leaves of the binary tree,
determine whether a node is a leaf node
and calculate the total node of the binary tree.
**
## rule
*
The binary tree construction rule uses the preorder rule to construct the binary tree.
*
If the first root node is followed by the left node at the right node,
*
if the input is an integer-1, the left or right subtree of the positive integer just entered in front of it is empty.
*
The last number 0 in the array indicates that all the positive integers that make up the tree have been entered.
## template
```
5 4 -1 3 2 -1 -1 1 -1 -1 6 -1 7 8 -1 -1 9 -1 -1 0
```
*
Enter the above set of data in the console window and the result of running the program will be as shown in the following:
```
============================================================
二叉树构造规则
采用先序规则构造二叉树,先根节点后左节点在右节点
如果输入的是整数 -1,
则表示其前面刚输入的正整数的左或右子树为空。
数组里最后出现的数字0
表示构成该树的所有正整数已输入完毕。
============================================================
请按照构造规则输入二叉树的结点数据:
5 4 -1 3 2 -1 -1 1 -1 -1 6 -1 7 8 -1 -1 9 -1 -1 0
先序递归遍历二叉树:
5 4 3 2 1 6 7 8 9
先序非递归遍历二叉树:
5 4 3 2 1 6 7 8 9
中序递归遍历二叉树:
4 2 3 1 5 6 8 7 9
中序非递归遍历二叉树:
4 2 3 1 5 6 8 7 9
后序递归遍历二叉树:
2 1 3 4 8 9 7 6 5
后序非递归遍历二叉树:
2 1 3 4 8 9 7 6 5
该二叉树的叶子结点的数目:4
该二叉树的深度:4
该二叉树总节点数目:9
```
* The compiler I use is Microsoft's Visual Studio 2017
binary tree
→
binary tree
.cpp
浏览文件 @
5dd0f19d
文件已移动
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录