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.

Five example expression trees

Evaluate the Trees

Evaluate each tree. The answer below each tree is the value of the entire expression.

Question

Tree 1 What is the evaluation of this tree?

13

Question

Tree 2 What is the evaluation of this tree?

8

Question

Tree 3 What is the evaluation of this tree?

14

Question

Tree 4 What is the evaluation of this tree?

38

Write the Postfix Expressions

Write a post-fix (RPN) expression for each tree.

Question

Tree 1 Write the post-fix expression for this tree.

7 2 * 5 3 - / 6 +

Question

Tree 2 Write the post-fix expression for this tree.

20 4 / 3 * 8 2 - 1 + -

Question

Tree 3 Write the post-fix expression for this tree.

60 5 / 4 - 2 / 3 + 2 *

Question

Tree 4 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.

Question

Tree 1 Write the infix expression for this tree.

(7 * 2) / (5 - 3) + 6

Question

Tree 2 Write the infix expression for this tree.

(20 / 4 * 3) - ((8 - 2) + 1)

Question

Tree 3 Write the infix expression for this tree.

((60 / 5 - 4) / 2 + 3) * 2

Question

Tree 4 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 + - *

Question

Draw the expression tree for 1 2 3 4 + - *.

Answer tree 1

2. 1 2 + 3 4 - 5 6 * * /

Question

Draw the expression tree for 1 2 + 3 4 - 5 6 * * /.

Answer tree 2