Exam-style question
Try this first
A depth-first search starts at A and considers neighbours in the order shown. A: B, C; B: D; C: E; D: F; E: F; F: none. Which is the order in which vertices are first visited?.
- A.A, B, C, D, E, F
- B.A, B, D, F, C, E
- C.A, C, E, F, B, D
- D.A, B, D, C, E, F
Model answer
What a good answer should say
- A, B, D, F, C, E
Explanation
Why this works
Depth-first search follows the first available branch as far as possible. It visits A, B, D and F before backtracking to C and then visiting E.
Common mistake
No common mistake is linked to this question yet.
