Exam-style question
Try this first
An expression tree has * as its root. Its left subtree has + as its root with leaves a and b, and its right subtree is the leaf c. What postfix expression is produced by a post-order traversal?.
- A.* + a b c
- B.a b + c *
- C.a b c + *
- D.+ a b * c
Model answer
What a good answer should say
- a b + c *
Explanation
Why this works
Post-order visits the left subtree, the right subtree, and then the current node. The left subtree produces a b +, followed by c, and then the root operator *, giving a b + c *.
Common mistake
No common mistake is linked to this question yet.
