资 源 简 介
#pragma once
template
struct Node
{
T _data;
Node* left;
Node* right;
Node(T val) :_data(val), left(NULL), right(NULL)
{}
~Node()
{}
};
template
class BinSearchTree
{
public:
BinSearchTree() :_root(0)
{}
void CreatTree(char* str)
{
int n = strlen(str);
CreatTree_(_root,str,n);
}
void comFather(char a,char b)
{
return comFather_(_root,a,b);
}
protected:
void comFather_(Node* root,char a,char b)
{
if (root->_data > a && root->_data < b)
{
cout << root->_data << endl;
return;
}
if (root->_data > a && root->_data > b)
comFather_(root->left, a, b);
if (root->_data < a && root->_data < b)
comFather_(root->right, a, b);
}
void insertVal(Node*& root, char ch)
{
if (root == NULL)
{
root = new Node(ch);
return;