ITPEC FE Morning April 2023 Question 7
ITPEC FE Morning April 2023 — Question 7 of 80
Pre-order Tree Traversal — visit root, then left subtree, then right subtree (NLR).
Given BST with root 9:
- •Visit
9→ left subtree rooted at3 - •Visit
3→ left child1 - •Visit
1(leaf) → back to3, right child6 - •Visit
6→ left child4 - •Visit
4(leaf) → right child7 - •Visit
7(leaf) → back to9, right subtree rooted at10 - •Visit
10→ left child14 - •Visit
14→ left child13 - •Visit
13(leaf)
Result: 9, 3, 1, 6, 4, 7, 10, 14, 13
Why not others:
- (a) 1, 3, 4, 6, 7, 9, 10, 13, 14 — this is in-order traversal (LNR, sorted BST output)
- (b) 1, 4, 7, 6, 3, 13, 14, 10, 9 — this is post-order traversal (LRN)
- (d) 9, 3, 10, 1, 6, 14, 4, 7, 13 — this is level-order traversal (BFS, layer by layer)
Key rule: Pre-order = NLR (Node, Left, Right). Always process root before children.
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.