Module M24 · 24 of 35 in teaching order · Intermediate

BFS and DFS

Breadth-first and depth-first search on graphs and grids, and what each one finds.

Lessons

  1. Breadth-first and depth-first search on adjacency lists: the visited set, distances and levels, discovery and finish order, back edges and cycles, grids, and O(V + E).

Topics this module covers

The full module scope. Topics without a lesson above are not written yet.

  • queue/stack
  • recursion
  • visited
  • components
  • cycles
  • grid traversal
  • flood fill
  • multi-source BFS
  • bipartite
  • comparison

Builds toward