void PostorderTraversal( BinTree Tree ) {
BinTree t = Tree;
if( t == NULL ) {
return;
}
BinTreeNode LastNode = NULL;
stack s = createStack();
initializeStack( s );
do {
while( t ) {
pushStack( s, t );
t = t->left;
}
t = topStack( s );
if( !t->r || LastNode == t->r ) {
LastNode = popStack( s );
printf("%d ", LastNode->data);
t = NULL;
}
else {
t = t->right;
}
}while( !judgeEmptyStack( s ) );
}
我看我之前的代码是错的,现在重新思考,再来复习一遍。