有关下面 C++ 代码不正确的说法是( )。
int Depth(BiTree T)
{
if (T == NULL)
{
return 0;
}
else
{
int m = Depth(T->lchild);
int n = Depth(T->rchild);
if (m > n)
{
return m + 1;
}
else
{
return n + 1;
}
}
}
- A. 该代码可用于求解二叉树的深度。
- B. 代码中函数
Depth( )的参数 T 表示根节点,非根节点不可以作为参数。 - C. 代码中函数
Depth( )采用了递归方法。 - D. 代码中函数
Depth( )可用于求解各种形式的二叉树深度,要求该二叉树节点至少有left和right属性。