大门|大门-CS-2007 |问题46

考虑下面的C程序段,其中CellNode表示二进制树中的一个节点:

null

struct CellNode
{
struct CellNOde *leftChild;
int element;
struct CellNode *rightChild;
};
int GetValue( struct CellNode *ptr)
{
int value = 0;
if (ptr != NULL)
{
if ((ptr->leftChild == NULL) &&
(ptr->rightChild == NULL))
value = 1;
else
value = value + GetValue(ptr->leftChild)
+ GetValue(ptr->rightChild);
}
return (value);
}


当二叉树的根指针作为其参数传递时,GetValue()返回的值为: (A) 树中的节点数 (B) 树中的内部节点数 (C) 树中的叶节点数 (D) 树的高度 答复: (C) 说明: 见本报告问题1 https://www.geeksforgeeks.org/data-structures-and-algorithms-set-12/ 这个问题的小测验

© 版权声明
THE END
喜欢就支持一下吧
点赞13 分享