实现一个先序遍历非递归算法。
解析:
void PreOrderUnrec(Bitree *t)
{Stack s;StackInit(s);Bitree *p = t;while (p != NULL || !StackEmpty(s))while (p != NULL) //遍历左子树{visite(p->data);push(s, p);p = p->lchild;}if (!StackEmpty(s)) //通过下一次循环中的内嵌while 实现右子树遍历{p = pop(s);p = p->rchild;}//endif
}//endwhile
}