In data structures, I get converting in order and pre-order formula conversions into trees. However, I'm not so good with post-order.
For the given formula x y z + a b - c * / -
I came up with
- / \ * / (divide) / \ / \ x + - c / \ /\ y z a b
For the most part, this seems to fit, except the * in the left subtree is the joker in the deck. In post order traversal, the last character is the top node of the tree, everything else branches down. Now I take the / and * operators to mean that they should be on opposing nodes. However, when traversing tree, everything fits except for the *, since the left subtree has to work up to the node prior to the root, then switch over to the right subtree.
A nudge in the right direction is appreciated.