二叉树深度的递归算法
输入深度(btree root ) . {
intldepth,rdepth;
if (! 路线)
返回0;
else.{
LDepth=Depth(root-Lchild );
rdepth=depth(root-rchild );
if(Ldepth=Rdepth(/左右子树的最大深度加1返回
returnldepth 1;
else
returnrdepth 1;
}
二叉树深度的递归算法
输入深度(btree root ) . {
intldepth,rdepth;
if (! 路线)
返回0;
else.{
LDepth=Depth(root-Lchild );
rdepth=depth(root-rchild );
if(Ldepth=Rdepth(/左右子树的最大深度加1返回
returnldepth 1;
else
returnrdepth 1;
}
版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。