//先根次序周游 非递归
void nPreOrderE(BinTree t)
{
Stack s;
BinTreeNode *c;
if(t == NULL) return ;
s = createNullStack(); //创建存储的空链栈
push(s,t); //树根进栈
while(!isEmptyStack(s)){
c = top(s); //顶部出栈
pop(s);
if(c!=NULL){
visit(root(c)); //周游根节点
push(s,rightChild(c)); //右节点进栈
push(s,leftChild(c)); //左节点进栈(后进先出)
}
}
}
//对称序周游 非递归
void nInOrder(BinTree t){
Stack s = createNullStack();
BinTree c = t;
do{
while(c!=NULL) {push(s,c); c = leftChild(c);} //遍历左子树,一直到最左的左子树
c = top(s);
pop(s); //弹出最左子树
visit(root(s)); //周游
c = rightChild(c); //最左子树是否有右节点
}while(!isEmptyStack(s)||c!=NULL);
}