Why breadth-first search (BFS) finds the shortest path and depth-first search (DFS) does not
Press → or Space to continue
| DFS | BFS | |
|---|---|---|
| Style | Goes deep first (Commitment) | Layer by layer (Coverage) |
| Memory | Usually lower | Usually higher |
| Shortest path | (not guaranteed) |