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

📄 main.cpp

📁 二岔搜索树 可完成基本操作 遍历 查找 删除 判断两树是否相等
💻 CPP
字号:
#include "bst.h"

int main()
{
	BST<int> bst1;

	int a[8] = {23, 45, 12, 9, 123, 87, 22, 9};
	for (int i = 0; i < 8; i++) {
		bst1.insert(a[i]);
	}

	cout << bst1.max() << endl;
	cout << bst1.min() << endl;

	int b = 145;
	if (bst1.find(b))
		cout << "successful" << endl;
	else
		cout << "cannot find " << b << endl;

	bst1.remove(b);
	
	BSTNode<int> *root = bst1.getRoot();
	if (root)
		cout << root->getData() << endl;

	
	BSTNode<int> *temp = bst1.leftChild(bst1.getRoot());
	if (temp)
		cout << temp->getData() << endl;	
	
	temp = bst1.parent(bst1.leftChild(bst1.leftChild(bst1.getRoot())));
	if (temp)
		cout << temp->getData() << endl;		


	bst1.inOrder();
	cout << endl;

	cout << bst1.size() << endl;

	cout << endl << bst1.depth() << endl << endl;

	BST<int> bst2 = bst1;

	if (bst2 == bst1)
		cout << "equal" << endl;
	else
		cout << "not equal" << endl;

	return 0;
}

⌨️ 快捷键说明

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