Non Recusive Traversal
Non Recusive Traversal
Right child is pushed before left child to make sure that left subtree is
processed first.
Iterative Postorder Traversal
The idea is to move down to leftmost node using left pointer. While moving
down, push root and root’s right child to stack. Once we reach leftmost node,
print it if it doesn’t have a right child. If it has a right child, then change root
so that the right child is processed before.
a) If the popped item has a right child and the right child
push the root back and set root as root's right child.
2.3 Repeat steps 2.1 and 2.2 while stack is not empty