已知二叉链表的类型定义如下: 以二叉链表作存储结构,试编写求二叉树叶子结点个数的算法leafnode_num(BinTree bt)。
int leafnode_num(BinTree bt){ if (bt== NULL)return0;elseif(bt->lchild== NULL)&& (bt->rchild== NULL)return 1;elsereturn leafnode_num(bt->lchild)+leafnode_num(bt->rchild);}
已知二叉链表的类型定义如下: 以二叉链表作存储结构,试编写求二叉树叶子结点个数的算法leafnode_num(BinTree bt)。
int leafnode_num(BinTree bt){ if (bt== NULL)return0;elseif(bt->lchild== NULL)&& (bt->rchild== NULL)return 1;elsereturn leafnode_num(bt->lchild)+leafnode_num(bt->rchild);}