字符串二叉排序树的构造问题
刚学会数据结构中数字的二叉排序树构造,但是不知道字符串的该怎么构造,比如输入一串英语单词然后以各单词为结点形成二叉排序树,烦请各位高手指教,最好能给几行简单的代码,谢谢大家!
程序代码:template<class T>
class BST;
template<class T>
class BSTnode
{
friend class BST<T>;
private:
T info;
BSTnode<T> *LeftChild;//左子树
BSTnode<T> *RightChild;//右子树
public:
BSTnode()
{
LeftChild=RightChild=NULL;
}
BSTnode(const T &ele)
{
info=ele;
LeftChild=RightChild=0;
}
BSTnode(const T &ele,BSTnode<T>*l,BSTnode<T>*r)
{
info=ele;
LeftChild=l;
RightChild=r;
}
};节点类的定义







