二叉树的层次遍历
借助队列实现
void levelOrder(BiTree T){
if(T==NULL) return;
InitQueue(Q);//初始化一个队列
EnQueue(Q,T);
while(QueueEmpty(s)!=NULL){
Dequeue(Q,T);
visit(T);
if(T->lchild!=NULL) Enqueue(Q,T->lchild); //左子树入队
if(T->rchild!=NULL) Enqueue(Q,T->rchild);//右子树入队
}
}