0PricingLogin
Competitive Programming Academy · Lesson

BFS for Shortest Unweighted Paths

Layer-by-layer distance from a source.

What BFS Does

BFS explores a graph in rings: first your start, then everything one step away, then two steps, and so on. 🌊

Why Rings Mean Shortest

Because BFS finishes each ring before the next, the first time it reaches a node is the shortest unweighted path to it.

All lessons in this course

  1. Adjacency Lists from Input
  2. BFS for Shortest Unweighted Paths
  3. DFS, Recursion & Iterative Stacks
  4. Connected Components & Flood Fill
← Back to Competitive Programming Academy