上传者: 43934844
|
上传时间: 2022-07-11 19:06:35
|
文件大小: 148KB
|
文件类型: DOC
实验题目 二叉树的基本操作 1. 实验目的与要求 实验目的: 1、实现二叉树的各种运算。 2、实现二叉树的各种遍历。 实验要求: 完成课本实验题7.1、实验题7.2要求实现的各项功能。 2. 实验方案 实验7-1 //文件名:algo7-1.cpp #include #include #define MaxSize 100 typedef char ElemType; typeder struct node { ElemType data; struct node*lchild; struct node*rchild; }BTNode; void CreateBTNode(BTNode *&b,char *str) { BTNode *St[MaxSize],*p=NULL; int top=-1,k,j=0; char ch; b=NULL; ch=str[j]; while(ch!='\0') { switch(ch) { case '(':top++;St[top]=p;k=1;break; case')':top--;break; case