Expression Tree Algorithms
Expression Tree Algorithms
1. Create a Stack.
2. Read the given postfix one symbol at a time, and repeat Steps 3 to 4.
o Pop out pointers to the two trees (T1(first popped out) and T2) from the stack.
o Create a new tree with the operator as the root and whose left-child
and right-child point to trees T2 and T1, respectively.
o Push the root pointer of this new tree back into the stack.
5.The stack will contain a single tree; return it as the final expression tree.