Two ways to walk a graph: ripple outward level by level, or dive deep and backtrack.

5 lessons · ~51 min · free

By the end you can

  1. Graphs, before the theory9 minNodes, edges, adjacency lists, and why a grid is already a graph.
  2. BFS: search in ripples12 minA queue, a visited set, and levels that double as shortest-path distances.
  3. DFS: go deep, then back up11 minRecursion as a path-walker, backtracking, and the visited set that stops infinite loops.
  4. Grids and islands11 minFlood fill in practice: counting islands, the directions array, and marking as you go.
  5. BFS or DFS?8 minShortest path says BFS, exhaustive exploration says either. A decision guide with the traps.

The account is free and so is every lesson. It unlocks the courses and saves your progress.

Practice it after

The final lesson links here too: real interview questions that test this pattern, in an editor with execution and AI feedback.