[prev] 15 [next]

Depth-first Search (cont)

Knowing whether a path exists can be useful

Knowing what the path is even more useful
⇒ record the previously visited node as we search through the graph    (so that we can then trace path through graph)

Make use of global variable:

  • visited[] … array to store previously visited node, for each node being visited