層次遍歷二叉樹

請讀者對比學習本博客非遞歸先序遍歷二叉樹html

http://www.javashuo.com/article/p-cwfsocix-kq.html算法

func(Tree T){學習

if(T==NULL){
    printf("樹空");
    return
}
Queue q;
EnQueue(q,T);
while(!IsEmpty(q)){
    DeQueue(q,T)
    visit(T);
    if(T->lchild)
        EnQueue(q,T->lchild);
    if(T->rchild)
        Enqueue(q,T->rchild);
}

}code


您可能感興趣的
htm

相關文章
相關標籤/搜索