//递归输出二叉树所有叶子结点
void DispLeaf(BTNode *b)
{
if(b!=null){
if(b->lchild==null&&b->rchild==null){
printf("%c",b->data);
DispLeaf(b->lchild);
DispLeaf(b->rchild);
}
}
}
//求值为x的结点的层次或者深度
int Level(BTNode *b,ElemType x,int h){
int l;
if(b==null)
return 0;
else if(b->data==x)
return h;
else{
l=Level(b->lchild,x,h+1);
if(l!=0)
return l;
else
return(Level(b->rchild,x,h+1));
}
}
二叉树常见的递归算法
最新推荐文章于 2023-04-06 19:55:58 发布
3860

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



