📄 binsorttree.h
字号:
///////////////////////////////////////////////////////////////
//
// 文 件 名: BinSortTree.h
// 创 建 者 刘志祥
// 创建时间: 2004-9-1
// 功能描述 二叉排序树的基本操作
//
/////////////////////////////////////////////////////////////////
#include <iostream.h>
struct BinNode
{
int data;
BinNode *lchild;
BinNode *rchild;
BinNode():lchild(NULL),rchild(NULL){}
BinNode(int d,BinNode *l=NULL,BinNode *r=NULL):data(d),lchild(l),rchild(r){}
};
class BinSortTree
{
private:
BinNode *root;
int SearchBST(BinNode *&T,int x,BinNode *f,BinNode *&p);
int InsertBST(BinNode *&T,int x);
int DeleteBST(BinNode *&T,int x);
void DeleteNode(BinNode *&T);
void print(BinNode *T);
public:
BinSortTree():root(NULL){}
BinSortTree(int a[],int n);
int InSert(int x){
return InsertBST(root,x);
}
int Delete(int x){
return DeleteBST(root,x);
}
void print(){
print(root);
cout<<endl;
}
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -