When dealing with graphs and trees, two useful approaches are Depth-First Search (DFS) and Breadth-First Search (BFS).

In particular, we use DFS when we need to do some type of pathfinding or when we need to explore all possible configurations, since the algorithm first explores the graph in the depth. While we use BFS when we need to find the minimum path length, since if explores as many paths as possible, but without going in depth.


tags: algorithms