非递归先序遍历二叉树

func(Tree T){

if(T==NULL){
    printf("树空");
    return;
}
Stack S;
push(S,T);
while(!IsEmpty(S)){
    pop(S,T);
    visit(T);
    if(T->rchild)
        push(S,T->rchild);
    if(T->lchild)
        push(S,T->lchild);
}

}


您可能感兴趣的

猜你喜欢

转载自www.cnblogs.com/Coeus-P/p/9353186.html