/*先序遍历*/
void Preorder(BiTree T)
{
if(T!=NULL)
{
visit(T);
Preorder(T->lchild);
Preorder(T->rchild);
}
}
/*中序遍历*/
void Inorder(BiTree T)
{
if(T!=NULL)
{
Inorder(T->lchild);
visit(T);
Inorder(T->rchild);
}
}
/*后序遍历*/
void Postorder(BiTree T)
{
if(T!=NULL)
{
Postorder(T->rchild);
Postorder(T->lchild);
visit(T);
}
}
/*层次遍历*/
void Levelorder(BiTree T)
{
BiTree p=T;
queue<BiTree> a;
a.push(p);
while(!a.empty())
{
p=a.front();
printf("%c ",p->data);
a.pop();
if(p->lchild!=NULL) a.push(p->lchild);
if(p->rchild!=NULL) a.push(p->rchild);
}
}