课程名称 数据结构 实验项目 动态查找表的设计与实现 实验目的 通过实验加深对二叉查找树的理解,学会根据给定的数据建立二叉查找树,在二叉查找树中查找、插入、删除元素。 实验内容(算法、程序、步骤和方法) 实验内容: 实现抽象数据类型:二叉查找树。 要求:实现下列操作:构造空表、销毁表、搜索指定关键字的元素、插入新元素、删除指定关键字的元素、遍历表中所有元素. 实验部分程序: / #define Maxsize 100 typedef struct BiTNode //定义二叉树节点结构 { int data; //结点的数据域 struct BiTNode *lchild,*rchild; //左右孩子指针域 }BiTNode,*BiTree; BiTNode *CreatBST(int A[],int n); int SearchBST(BiTree,int,BiTree,BiTree&); //在二叉排序树中查找元素 int InsertBST(BiTree &,int); //在二叉排序树中插入元素 int DeleteBST(BiTree &,int); //在二叉排序树中删除元素 void Delete(BiTree &); //删除二叉排序树的根结点 void InorderBST(BiTree); //中序遍历二叉排序树,并显示 int A[Maxsize]; void main() { BiTree T,p; int ch,keyword; char j='y';//控制程序结束与否 int temp; printf("-------------------------Identification-------------------------------\n"); printf("This program will show how to operate to a Binary Sort Tree.\n"); printf("You can display all elems,search a elem,ninsert a elem,delete a elem.\n"); printf("----------------------------------------------------------------------\n"); int n; printf("Please input the number of the node:\n");//输入开始建立的二叉树的结点个数 scanf("%d",&n); printf("Please input every node:\n"); for(int i=0;i