已知二叉树的链式存储结构为: typedef struct node { char data; struct node *lchild, *rchild; } BiTree; 用递归算法中序遍历求二叉树的叶子结点个数,请将下面的算法补充完整。 /*已知二叉树root,求该二叉树的叶子结点个数*/ int leafinorder(BiTree *root)//用中序遍历的方法求二叉树的叶子结点数 {int n=0; if(root!=NULL) {leafinorder(root->lchild); if((root->lchild==NULL)&&() {n=n+1; printf("%c\t",root->data); } () } return n; }
发布时间:2024-03-26 05:01:26