【二叉树】求树的高度(深度)

来源:互联网 发布:四知文言文翻译 编辑:程序博客网 时间:2024/05/22 05:22
//求二叉树的深度int GetDepth(bnode *root){    if(root == NULL)    {        return 0;    }    int leftDepth = GetDepth(root->pLeft);    int rightDepth = GetDepth(root->pRight);    return (leftDepth > rightDepth ? leftDepth : rightDepth) + 1;}

原创粉丝点击