int Dep(Bianary *root)
{
if (root == NULL)
{
return 0;
}
int depth = 0;
int leftD = Dep(root->lchild);
int rightD = Dep(root->rchild);
depth = leftD > rightD ? leftD + 1 : rightD + 1;
return depth;
}
递归理解:
int Dep(Bianary *root)
{
if (root == NULL)
{
return 0;
}
int depth = 0;
int leftD = Dep(root->lchild);
int rightD = Dep(root->rchild);
depth = leftD > rightD ? leftD + 1 : rightD + 1;
return depth;
}
递归理解: