在深度为n的满二叉树中,求叶子结点

来源:百度知道 编辑:UC知道 时间:2024/05/04 03:44:52

没事干写着玩的,可能不符合你的要求
#include<alloc.h>
#include<stdio.h>
typedef struct Node
{
char data;
struct Node *lchild,*rchild;

}Node;

void countleaf(Node *head,int *count)
{
if(head!=NULL)
if(head->lchild==NULL)&&(head->rchild==NULL)
{
(*count)++;
return;
}
countleaf(head->lchild,count);
countleaf(head->rchild,count);
}
void main()
{
int count=0;
countleaf(head,count);
}

2^(n-1)个
在二叉树中,第i层的结点总数不超过2^(i-1);
(2) 深度为h的二叉树最多有2h-1个结点(h>=1),最少有h个结点;
(3) 对于任意一棵二叉树,如果其叶结点数为N0,而度数为2的结点总数为N2, 则N0=N2+1;
(4) 具有n个结点的完全二叉树的深度为int(log2n)+1

2的(N-1)次方 这个是公共基础知识里面的内容!
计算机2级都考完了,呵呵

问题不明确