I have been trying this for a while but have not succeeded can someone please help me with it.
Here is the Wikipedia Link for Iterative(Non Recursive )Post Order traversal in a binary tree.
The pseudo-code as given in Wikipedia is::
iterativePostorder(rootNode) nodeStack.push(rootNode) while (! nodeStack.empty()) currNode = nodeStack.peek() if ((currNode.left != null) and (currNode.left.visited == false)) nodeStack.push(currNode.left) else if ((currNode.right != null) and (currNode.right.visited == false)) nodeStack.push(currNode.right) else print currNode.value currNode.visited := true nodeStack.pop()
The pseudo code is quite easy ,try to go through it .