#depth-first-search
Depth-First Search (DFS)
Introduction Depth-First Search (DFS) is a fundamental graph traversal algorithm that explores as far as possible along each branch before backtracking. Think of it like exploring a maze by always taking the first path you see, going as deep as possible, then backtracking when you hit a dead end. DFS is essential for detecting cycles, topological sorting, finding connected components, and solving maze/puzzle problems. Unlike BFS which uses a queue, DFS uses a stack (or recursion, which implicitly uses the call stack). Read more →
November 19, 2025