Expression Tree - Examples
This page is specific for Examples of Expression Trees along with expressions. To learn about Expression Tree Traversals, please click on links above.
Expression Tree is used to represent expressions. Let us look at some examples of prefix, infix and postfix expressions from expression tree for 3 of the expresssions:
- a*b+c
- a+b*c+d
- a+b-c*d+e*f
Expressions from Expression Tree
Infix expression | a * b + c |
Prefix expression | + * a b c |
Postfix expression | a b * c + |
Infix, Prefix and Postfix Expressions from Expression Tree for a+b*c+d
Expression Tree for a + b * c + d can be represented as:
Expressions for the binary expression tree above can be written as
Infix expression | a + b * c + d |
Prefix expression | * + a b + c d |
Postfix expression | a b + c d + * |
Infix, Prefix and Postfix Expressions from Expression Tree for a+b-c*d+e*f
Expression Tree for a + b - c * d + e * f can be represented as:
Expressions for the binary expression tree above can be written as
Infix expression | a + b - c *d + e * f |
Prefix expression | * + a - b c + d * e f |
Postfix expression | a b c - + d e f * + * |