ITPEC FE Subject A April 2025 Question 6
ITPEC FE Subject A April 2025 — Question 6 of 60
Depth-First Search (DFS) — Alphabetical Order Traversal
The question asks for the DFS traversal starting from vertex A, visiting neighbors in ascending alphabetical order.
This corresponds to DFS using a stack (LIFO): we go as deep as possible, and the last added neighbor is visited first.
Result: A B D F E C
Why not others:
- a) A B C D E F: This is level-order traversal (BFS), not DFS
- b) A B C D F E: Goes to C too early, breaking DFS depth-first rule
- c) A B D E F C: Incorrect order within D’s subtree
- d) ✅ A B D F E C: Correct DFS traversal with stack behavior
Key rule: "DFS goes deep first; stack (LIFO) means last added neighbor is visited first."
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.