Expression Trees
Expression trees show the structure of an arithmetic expression. Operators are internal nodes, and numbers are leaves.
Examples
The following trees are shown with their evaluations.
Evaluate the Trees
Evaluate each tree. The answer below each tree is the value of the entire expression.
What is the evaluation of this tree?
13
What is the evaluation of this tree?
8
What is the evaluation of this tree?
14
What is the evaluation of this tree?
38
Write the Postfix Expressions
Write a post-fix (RPN) expression for each tree.
Write the post-fix expression for this tree.
7 2 * 5 3 - / 6 +
Write the post-fix expression for this tree.
20 4 / 3 * 8 2 - 1 + -
Write the post-fix expression for this tree.
60 5 / 4 - 2 / 3 + 2 *
Write the post-fix expression for this tree.
12 2 / 3 + 4 * 20 5 / 2 - +
Write the Infix Expressions
Write an infix (normal math) expression for each tree. Include parentheses where they make the tree structure clear.
Write the infix expression for this tree.
(7 * 2) / (5 - 3) + 6
Write the infix expression for this tree.
(20 / 4 * 3) - ((8 - 2) + 1)
Write the infix expression for this tree.
((60 / 5 - 4) / 2 + 3) * 2
Write the infix expression for this tree.
(12 / 2 + 3) * 4 + (20 / 5 - 2)
Draw the Expression Trees
Draw the tree corresponding to each RPN expression. Work from left to right, making each operator the parent of the two values immediately below it.
1. 1 2 3 4 + - *
Draw the expression tree for 1 2 3 4 + - *.
2. 1 2 + 3 4 - 5 6 * * /
Draw the expression tree for 1 2 + 3 4 - 5 6 * * /.