Depth-first search follows an unvisited neighbor until it reaches a dead end, then backtracks through a call stack or explicit stack.
Without a visited set, cycles can repeat forever. Unlike breadth-first search, DFS does not directly guarantee a minimum-hop path in an unweighted graph.
When to use
Use it for connected components, cycle checks, and backtracking search.