๐ฎ BFS / DFS (Practice)
Companion to the BFS & DFS guide. Watch BFS explore a graph level by level, then implement it with a queue.
๐ฌ Watch it workโ
BFS โ level-by-level explorationStep 1 / 13
Start BFS at node 1; enqueue it.
๐ Your turnโ
Loading editorโฆ
๐ง Challenge yourselfโ
- Rewrite it as DFS using a stack (or recursion).
- Modify BFS to return the shortest-path distance from start to every node.
- How would you detect a cycle during traversal?
Continue the path โ Hashing Patterns