Construct an expression tree for the expression a +( bc )* d +( e * f)
Construct an expression tree for the expression a +( bc )* d +( e * f)
Construct an expression tree for the expression a +( bc )* d +( e * f)
Best answer
Answer: Taking "bc" as \(b \times c\), the expression is \(\big(a + ((b*c)*d)\big) + (e*f)\), so the root is the last + and the tree is:
+
/ \
+ *
/ \ / \
a * e f
/ \
* d
/ \
b cHow to build it
Check: the postorder traversal of this tree gives the postfix form a b c * d * + e f * +, which evaluates the expression correctly.
Log in or create a free account to answer this question.