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
Answer and explanation
Concise answer
a b + c *
Why this is correct
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 *.
Use the concise answer above for a quick check, then reveal the full model answer and detailed explanation.
Common mistake
No common mistake is linked to this question yet.
