习题6.6

来源:互联网 发布:swisse护肝片 知乎 编辑:程序博客网 时间:2024/05/03 13:39
 
///习题6.6 判定完全二叉树int judgewq (BiTree T){BiTree bt = T ;LinkQueue btqu ;InitQueue(&btqu) ;int flag = 0 ;//if (bt != NULL){EnQueue(&btqu , bt) ;while(!QueueEmpty(btqu) ){DeQueue(&btqu ,  &bt) ;if (bt -> lchild != NULL && flag == 0)EnQueue(&btqu , bt -> lchild) ;else if (bt -> lchild != NULL){cout <<"不是完全二叉树" ;return 0 ;}else{flag = 1 ;}if (bt -> rchild != NULL  && flag == 0){EnQueue(&btqu , bt -> rchild) ;} else if (bt -> rchild != NULL){cout <<"不是完全二叉树" ;return 0 ;} else{flag = 1 ;}} }cout <<"是完全二叉树" ;return 0;}