二叉树的构建与遍历
发布时间
阅读量:
阅读量
文章结构概览
-
- 规定
- 程序代码
- 规定
要求
需完成非递归形式的前序、中序与后序遍历,并额外增加层次遍历,共计四种方式。
代码
#include<bits/stdc++.h>
#include<queue>
using namespace std;
char ch;
const int MAXSIZE = 100;
typedef struct BiTNode {
char data;
struct BiTNode *lchild, *rchild;
}BiTNode, *BiTree;
BiTNode *T;
BiTree q, p;
typedef struct{//定义顺序栈
BiTree *base;
BiTree *top;
int stacksize;
}SqStack;
SqStack S;
int InitStack(SqStack &S){
// S.base = new BiTree[MAXSIZE];
S.base = (BiTree*)malloc(sizeof(BiTNode)*MAXS
全部评论 (0)
还没有任何评论哟~
