Expression Trees
Expression Trees
• The first two symbols are operand, so create a one node tree and
push the pointer on to the stack.
ab + c *
• Next ‘+’ symbol is read, so two pointers are popped, a new tree is
formed and a pointer to this is pushed on to the stack.
ab + c *
• Next the operand C is read, so a one node tree is created and the
pointer to it is pushed onto the stack
ab + c *
•Now ‘*’ is read, so two trees are merged and the
pointer to the final tree is pushed onto the stack
Numeric Postfix expression
• Step 1: Construct the Expression Tree