判断是否是满二叉树

typedef struct infor
{
int height;
int number;
}infor;

infor *fullTree(node *p)
{
infor *IF=malloc(sizeof(infor));
IF->height=0;
IF->number=0;
if(p==NULL)
return IF;

infor *IF_left=fullTree(p->left);
infor *IF_right=fullTree(p->right);

IF->number=IF_left->number+IF_right->number+1;
if(IF_left->height>=IF_right->height)
IF->height=IF_left->height+1;
else
IF->height=IF_right->height+1;

return IF;
}

全部评论

相关推荐

点赞 评论 收藏
转发
点赞 收藏 评论
分享
牛客网
牛客企业服务