ITPEC FE Subject A October 2024 Question 5
ITPEC FE Subject A October 2024 — Question 5 of 60
Expression Tree (In-order Traversal) — evaluate an arithmetic expression from a binary tree.
Evaluate bottom-up (leaves → root):
- •
+:2 + 3=5 - •
*:5 × 10=50 - •
-:50 − 10=40 - •
/:40 / 2= `20`
Why not others:
- (a) 11 — misapplies operator precedence ignoring tree structure
- (c) 27 — likely error in subtraction or division order
- (d) 45 — skips the division step
Key rule: In an expression tree, operators are internal nodes, operands are leaves. Always evaluate bottom-up — the tree structure defines precedence, not standard math rules.
AI-generated — may contain errors
The original exam layout is preserved in the image so diagrams, formulas, tables, and code remain accurate.
This question comes from an official ITPEC past paper. ITPEC Practice is an independent study tool and is not affiliated with ITPEC. See the official FE past-paper collection or Report an issue.