⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 binsorttree.h

📁 这里我在学习数据结构时的练习,主要是二叉排序树的基本操作
💻 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 + -