\begin{algorithm} \caption{Binary Tree Traversal Nonrecursive} \begin{algorithmic} \REQUIRE a binary tree $T$ \ENSURE print all keys appearing in $T$ \STATE Let $S$ be a stack \STATE \CALL{Push}{$S, T.root$} \WHILE{\NOT \CALL{StackEmpty}{$S$}} \STATE $x =$ \CALL{Pop}{$S$} \IF{$x == NIL$} \CONTINUE \ENDIF \PRINT $x.key$ \STATE \CALL{Push}{$x.right$} \STATE \CALL{Push}{$x.left$} \ENDWHILE \end{algorithmic} \end{algorithm}