Computer scienceAlgorithms and Data StructuresAlgorithmsGraph algorithmsGraph search algorithms

Depth-first search

Applying DFS

Report a typo

Apply the DFS procedure for the following undirected graph:

Applying DFS

Start the algorithm with the node 44. If there are several nodes to choose to process next, pick the one with the smallest label.

Print the resulting spanning tree for the graph in the following format:

1 -> 2
2 -> 3
3 -> 4
4 -> 5

Here, each line represents an edge. In your output, the edges should be printed in the order of traversal.

Enter a short text
___

Create a free account to access the full topic