Depth-First Search (DFS) is one of the two fundamental ways to systematically visit every vertex in a graph. The strategy is simple to state: from the current vertex, follow one edge as deep as you can, and only when you run out of unvisited neighbors do you back up (backtrack) and try another branch. That "go deep first" behavior is what separates DFS from BFS, which fans out level by level.
In this course, DFS matters for two reasons. First, it is a building block: cycle detection, topological sorting, finding connected components, path existence checks, and maze/puzzle solving are all DFS in disguise. Second, it is a good test of your understanding of recursion and explicit stacks — the recursive version hides the stack in the call stack, while the iterative version makes that stack visible, and the two can produce different (but equally valid) visit orders.
As you watch, keep a short checklist in mind: Where is the visited set maintained, and when is a vertex marked visited (on push, or on pop)? How is backtracking actually happening? What happens if the graph is disconnected — how does the algorithm restart from an unvisited vertex? And how would the same pseudocode map onto an adjacency list in your own Graph class? Try tracing each example by hand on paper before the video reveals the answer.
A theory-plus-code walkthrough from the Geekific channel that explains the DFS idea and then implements it, with Java used as the demonstration language and the source posted on GitHub. Expect coverage of how DFS explores a branch fully before backtracking, how visited vertices are tracked, and how the traversal is driven over a graph structure. The accompanying repository lets you read the finished implementation line by line after watching.",
It pairs the conceptual explanation with a concrete implementation, which supports both the "DFS Core Concept and Strategy" and the implementation subtopics; the logic translates directly to JavaScript even though the demo code is Java.
A tightly edited four-minute explanation of depth-first search from Michael Sambol, a channel known for concise, animation-driven algorithm summaries. In roughly the length of a coffee break it walks through how DFS descends along a path and backtracks, with Python reference code linked in the description. It is the kind of video you can rewatch several times while tracing your own example graph.
It is an excellent first exposure or quick review: short, accurate, and focused on traversal order and the deep-then-backtrack strategy, which is exactly what you need to trace DFS by hand on an exam.
Dinesh Varyani devotes nearly eighteen minutes to the iterative, stack-based form of DFS on an undirected graph, using step-by-step animation. The extended runtime allows the push/pop sequence, the state of the explicit stack, and the visited marking to be shown frame by frame as the traversal unfolds. It is part of a larger data-structures-and-algorithms series.
It directly targets the "Iterative DFS Implementation" and "DFS Traversal Order and Visited Tracking" subtopics, and the slow animated trace makes clear why the iterative visit order can differ from the recursive one.
Together these three videos carry the DFS half of MO3, MO4, and MO5. The Sambol video gives you the compact mental model needed to trace DFS order by hand (MO3), while the Geekific video shows a full recursive implementation over a graph structure and the Varyani video shows the explicit stack version — between them they cover both approaches you must be able to write in your own Graph class (MO4). Watching all three also surfaces the practical side of DFS — path finding, component discovery, and backtracking-style search — which you will draw on when justifying DFS versus BFS for a given scenario (MO5). Note that none of these videos focus on adjacency matrix versus adjacency list trade-offs (MO2) or on choosing directed versus undirected models (MO1); rely on the module readings and other videos for those outcomes, and be sure to supplement with practice on disconnected graphs, where an outer loop must restart DFS from each unvisited vertex.
These videos were chosen from YouTube on October 2, 2026. Each has captions; the player turns them on. Videos on YouTube can be changed or removed — if one no longer plays, tell your instructor. If a player does not appear, use its Watch on YouTube link.