Algorithms, Data Structures, DFS, Bfs, Graphs.
node has no more unvisited neighbours (dead end), DFS backtracks to the previous node on the stack (if using a stack) or returns from the recursive call (if using recursion). This backtracking allows the algorithm to explore other branches and paths in the graph. 6. Repeat steps 3 to 5: DFS