views:

103

answers:

3

In-order tree traversal obviously has application; getting the contents in order.

Preorder traversal seems really useful for creating a copy of the tree.

Is there a common use for postorder traversal of a binary tree?

+2  A: 

For getting it in a different order, such as postfix: http://en.wikipedia.org/wiki/Reverse_Polish_notation

Steven Sudit
The HP calculator syntax springs to mind. +1
Dean J
Yes, postfix is ideal for evaluating expressions on a stack. It's also unambiguous about order of operations, unlike infix.
Steven Sudit
This answer appears to be correct, so why was it downvoted?
Steven Sudit
A: 

Yes. Postorder is sometimes used to translate mathematical expressions between different notations.

Sushisource
+1  A: 

Let me add another one:

Postorder traversal is also useful in deleting a tree. In order to free up allocated memory of all nodes in a tree, the nodes must be deleted in the order where the current node can only be deleted when both of its left and right subtrees are deleted.

Postorder does exactly just that. It processes both of the left and right subtrees before processing the current node.

1337c0d3r
That's actually the most useful answer I've heard so far; welcome!
Dean J