- 0
- 0
- 约5.2千字
- 约 6页
- 2019-09-16 发布于江西
- 举报
实验4 二叉树创建、遍历操作与应用
1实验目的
掌握使用先序方式创建二叉树;
掌握使用递归的方式对二叉树进行先序、中序和后序遍历操作;
掌握层次遍历;
二叉树的具体应用,如计算叶子结点个数,计算二叉树的深度。
2实验内容
以先序方式创建二叉链表存储结构的二叉树;
对二叉树进行先序、中序和后序遍历操作;
层次遍历二叉树。
求二叉树的深度以及叶子结点个数;
【测试数据】自定
参考程序如下:
# include malloc.h
# include iostream.h
# include conio.h
# include stdlib.h
# define OK 1
# define ERROR 0
# define OVERFLOW 0
# define MAXQSIZE 100
typedef char TElemType;
typedef struct BiTNode //define binary tree data struct
{ TElemType data;
struct BiTNode *lchild,*rchild;
}BiTNode, *BiTree;
typedef BiTree QElemType;
typedef struct SqQueue //define structure SqQueue
{ QElemType* bas
原创力文档

文档评论(0)