-
Postfix/Prefix
heeelp.
I've got a test tomorrow on binary / expression trees, and I understand it all except this whole concept of writing expressions in prefix/postfix/infix. My teacher worked through changing the expression a term at a time, but I always seem to get stuck near the end...
Code:
6 + (5 + 1) * (3 - 2) ^ 2
How would I express this in pre/post fix?
-
If you know the expression tree part its all easy, traverse the tree around from the left side, and write down from left to right each node you hit for the first time to get prefix notation, and do the same but when you hit for the third time (imagine all nodes that dont have two leafs have a dummy nodes instead) you get the postfix notation.