参考答案和解析
参考答案:
更多“设计递归算法计算以二叉链表存储的二叉树的叶子结点数目。 ”相关问题
  • 第1题:

    下列算法的功能是:统计二叉树中叶子结点的个数,二叉树以二叉链表存储,请填空。 typedef struct BiTNode{ TElemType data; struct BiTNode *lchild; struct BiTNode *rchild; }BiTNode,*BiTree; int CountLeaves(BiTree BT,int &count) { if((1) ) { if((2) ) count++; (3) ; (4) ; } return (count); }


    C

  • 第2题:

    设一棵二叉树以二叉链表为存储结构,试编写一个函数int LeafCount(BiNode *root),求二叉树中叶子结点的个数。 typedef struct Node {int data; struct Node *lchild,*rchild; } BiNode;


    B

  • 第3题:

    设一棵二叉树T以二叉链表为存储结构,试编写一个函数int LeafCount(BiNode *T),求二叉树中叶子结点的个数。 typedef struct Node {int data; struct Node *lchild,*rchild; } BiNode;


    B

  • 第4题:

    写出下列算法 统计二叉树中叶子结点的个数。二叉树的链式存储:


    int leaf_b(BiTree root) { int LeafCount; if(root==NULL) LeafCount =0; else if((root->LChild==NULL)&&(root->RChild==NULL)) LeafCount =1; else LeafCount =leaf_b(root->LChild)+leaf_b(root->RChild); /* 叶子数为左右子树的叶子数目之和 */ return LeafCount; }

  • 第5题:

    已知二叉树以二叉链表结构存储,根指针为root,结构类型定义如下。请编写递归算法统计叶子结点个数。 typedef struct node { char data; struct node *lchild,*rchild; }BiNode,*BiTree;


    错误