首页 > 代码库 > 二叉树 - 最大左高树

二叉树 - 最大左高树

MaxHBLT.h

#include <iostream>


template <typename T>
inline void Swap(T& a, T& b)
{
	T c = a;
	a = b; 
	b = c;
}
template <typename T> class MaxHBLT;

template <typename T>
class TNode
{
	friend MaxHBLT<T>;
public:
	TNode(const T& val)
	{
		data = http://www.mamicode.com/val;>

main.cpp

#include <iostream>
#include "MaxHBLT.h"

using namespace std;
int main()
{
	MaxHBLT<int> a;
	int b;
	for (int i = 1; i <= 20; ++i)
	{
		b = rand();
		a.insert(b);
	}
	a.show();
	cout <<endl;
	for (int i = 1; i <= 20; ++i)
	{
		a.del(b);
		cout <<"delete:" <<b <<endl;
	}
	a.show();
	for (int i = 1; i <= 20; ++i)
	{
		b = rand();
		a.insert(b);
	}
	a.show();
	cout <<endl;
	cout <<a.high() <<endl;
	cin.get();
	cin.get();
	return 0;
}


二叉树 - 最大左高树