//非递归后序遍历
void BinaryTreePostNonR(BTNode* root){
char tag[64];
BTNode* cur = root;
Stack st;
StackInit(&st, 100);
do{
for (; cur; cur = cur->lchild){
StackPush(&st, cur);
tag[st.size - 1] = 0;
}
while (!StackIsEmpty(&st) && tag[st.size - 1]){
cur = StackTop(&st);
putchar(cur->data);
StackPop(&st);
}
if (!StackIsEmpty(&st)){
cur = StackTop(&st);
tag[st.size - 1] = 1;
cur = cur->rchild;
}
} while (!StackIsEmpty(&st));
StackDestory(&st);
}
07-23
676
11-23
1685