11

不定项选择题 11 /123

设t是给定的一棵二叉树,下面的递归程序count(t)用于求得:
typedef struct node
{
    int data;
    struct node *lchild,*rchild;
}node;

int N2 = 0,NL = 0,NR = 0,N0 = 0;
void count(node *t)
 {
     if (t->lchild!=NULL)
         if (t->rchild!=NULL) N2++;
         else NL++;
     else if (t->rchild!=NULL) NR++;
     else N0++;
     if(t->lchild!=NULL) count(t->lchild);
     if(t->rchild!=NULL) count(t->rchild);
 }/* call form :if(t!=NULL) count(t);*/

参考答案

N0为左、右两个儿子均非空的结点个数
NL为左儿子非空、右儿子为空的节点个数
NR为右儿子非空、左儿子为空的节点个数
N2为叶子结点个数