binsearchmain1.cpp

来自「二叉搜索树的基本操作」· C++ 代码 · 共 33 行

CPP
33
字号
#include <iostream.h>
#include <stdlib.h>
#include"binSearchTree1.h"

void main()
{
	ElemType a[10] ={ 30,50,20,70,25,54,80,23,92,40};
	BSTNode* bst =NULL;
	ElemType x=70;
	CreateBSTree(bst,a,10);
	cout<<"建立的二叉搜索树的广义表形式为:"<<endl;
	PrintBSTree(bst);cout<<endl;
	cout<<"中序遍历:"<<endl;
	Inorder(bst);
	cout<<endl;
    if(Find(bst,x))
		cout<<"查找成功!得到的x为:"<<x<<endl;
	else
		cout<<"查找失败!"<<endl;
	Insert(bst,36);
	Delete(bst,30);
	Delete(bst,70);
	Delete(bst,40);
	cout<<"操作后的中序遍历为"<<endl;
	Inorder(bst);
	cout<<endl;
    cout<<"操作后的二叉搜索树的广义表形式为:"<<endl;
	PrintBSTree(bst);cout<<endl;
    ClearBSTree(bst);
}


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?