/*对二叉树的操作主要通过递归实现,递归能把一个复杂的问题最大程度的简化。以前实现二叉树主要通过C语言实现的,现在正在学习CORE C++,故决定用C++重新实现...*/
#ifndef _TREE_H_
#define _TREE_H_
#include
using namespace std;
template
class Tree //binary sort tree
{
struct Node
{
T data;
Node *left;
Node *right;
};
Node *root;
public:
Tree():root(NULL){};
void add(T value)//add element to tree
{
Node *n = new Node;
n->data = value;
n->left = NULL;
n->right = NULL;
insert(root,n);
}
void show(){ preShow(root); cout<
void sortShow(){ midShow(root); cout<
void clear(){ clearTree(root);};//clear the tree
int count(){//calculate the node's count of tree
return count(root);
}