Skip to content
Free public beta until December 4, 2026: every course is open, no card needed. After that, the first chapter of each course stays free and full access is a one-time $39 ($19 for up to 100 founding members chosen for helpful feedback). Your progress is kept. How the beta works

breadth-first search and depth-first search

Two systematic ways to visit every vertex of a graph reachable from a start vertex: BFS fans out level by level, DFS plunges as deep as possible before backing up.

Breadth-first search (BFS) visits vertices in order of increasing distance from the start, using a queue. Depth-first search (DFS) follows one path as far as it can before backtracking, using a stack (or recursion).

Read the full section →
Graph settings

Calculator