Depth-First Search
Primary data structure: Stack or recursion stack.
Explores deeply before backtracking.
Useful for connectivity and cycle detection.
Iterative DFS uses an explicit stack.
Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.