bool IsComplete(BiTree T){
if(T==NULL)return false;//空树不是
InitQueue(Q);
EnQueue(Q,T);
BiTree p;
while(!IsEmpty(Q)){
p=Front(Q);
if(p->lchild!=NULL&&p->rchild!=NULL){
DeQueue(Q);
EnQueue(Q,P->lchild);
EnQueue(Q,P->rchild);
}
if(p->lchild==NULL&&p->rchild!=NULL){
return false;
}//如果某一结点左孩子为空,右孩子非空,则一定不是完全二叉树
if(p->lchild!=NULL&&p->rchild==NULL||
p->lchild==NULL&&p->rchild==NULL){
//如果有结点左孩子非空,右孩子为空,或者出现叶结点
//则后面的结点全是叶结点
DeQueue(Q);
while(!IsEmpty(Q)){
p=Front(Q);
if(p->lchild==NULL&&p->rchild==NULL){
DeQueue(Q);
}else{
return false;
}
}
return true;
}
}
return true;
}