...

/

Challenge: Implement Depth-First Search

Challenge: Implement Depth-First Search

In this lesson, you have to implement the depth-first search algorithm. A solution is placed in the "solution" section to help you, but we suggest you try to solve it on your own first.

Problem statement

In this exercise, you have to implement the depth-first search traversal in Java. It is a searching algorithm for the graph which traverses down each branch depth-wise and backtracks after reaching a leaf node. We will use our already-implemented graph class for this task (since we have already covered the implementation of graph). ...