Skip to content
Insight CodeAcademy

Graphs

1 article

DSA6 min read

BFS vs DFS: Which Traversal Should You Use?

In this article we will learn how breadth-first search and depth-first search actually differ, why BFS finds the shortest path in an unweighted graph and DFS does not, how their memory usage compares on wide and deep graphs, and a decision rule for choosing between them in an interview.