How Is BFS Better Than DFS?

TIME : 2016-01-08
How Is BFS Better Than DFS?

Breadth-First Search (BFS) has a few clear advantages over Depth-First Search (DFS). Because BFS explores level by level, it finds the shortest path in an unweighted graph, which DFS can't guarantee. BFS is also better when the solution is likely close to the starting node, since it won't get lost going deep down one branch.

DFS, on the other hand, can be more memory-efficient for deep or very large graphs. So the "better" choice really depends on your specific problem.