logo

AQA A-Level Computer Science practice

A depth-first search is used to navigate a maze. From S, the available routes are considered in this order: S connects to A and B; A connects to C; C connects to D; D is a dead end; B connects to E; E connects to G. Trace the order of first visits until G is reached, including the backtracking that is needed.

Try the question first, then check the answer and practise the same topic again.

At a glance

Question

Type

practice

Style

Topic

Graph-traversal

Exam-style question

Try this first

A depth-first search is used to navigate a maze. From S, the available routes are considered in this order: S connects to A and B; A connects to C; C connects to D; D is a dead end; B connects to E; E connects to G. Trace the order of first visits until G is reached, including the backtracking that is needed.

Answer and explanation

Concise answer

The first-visit order is S, A, C, D, B, E, G.

Why this is correct

Depth-first search follows the first route as far as it can. After reaching D, there is no unvisited continuation, so it backtracks through C and A to S. It then explores B, followed by E, and reaches G.

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.

Related flashcards

No flashcards are published for this page yet.

Related practice questions