二叉树的构造函数算法BiTree由刀豆文库小编整理,希望给你工作、学习、生活带来方便,猜你可能喜欢“关于二叉树的所有算法”。
template
BiTree ::BiTree(BiNode *root){
creat(root);
}
template
void BiTree ::Creat(BiNode *root){
cin>>ch;
if(ch=='# ')root=NULL;//建立一棵空树else {
root=new BiNode;//生成一个结点root->data=ch;
Creat(root->lchild);//递归建立左子树Creat(root->rchild);//递归建立右子树}
}