Graph Depth-First Search

code data_structures algorithms
Practice Quiz →
Figure:

Depth-First Search (DFS) is a graph traversal algorithm that explores as far as possible along one path before backtracking. Starting at a source node, DFS visits an unvisited neighbor, then a neighbor of that neighbor, continuing in a straight line until it reaches a node with no unvisited neighbors. At that point, the algorithm backtracks to the most recent node that still has an unvisited neighbor and continues branching from there.

💬 Click on the content to Ask AI
data structures algorithms graphs search recursion stack python java c complexity