1、前序遍历
2、中序遍历
3、后序遍历
//前序遍历的递归算法
void PreOrder(bitree* root)
{
if (root != NULL)
{
printf("%c", root->data);
PreOrder(root->lchild);
PreOrder(root->rchild);
}
}
//中序遍历的递归算法
void InOrder(bitree* root)
{
if (root != NULL)
{
InOrder(root->lchild);
printf("%c", root->data);
InOrder(root->rchild);
}
}
//后序遍历的递归算法
void PostOrder(bitree* root)
{
if (root != NULL)
{
PostOrder(root->lchild);
PostOrder(root->rchild);
printf("%c", root->data);
}
}
本文详细介绍了二叉树的前序遍历、中序遍历和后序遍历的递归算法实现。通过示例代码,帮助读者理解三种遍历方式的区别和应用。
3304

被折叠的 条评论
为什么被折叠?



