Providence Interview Question

What is the difference between DFS and BFS. When do we use them?

Interview Answer

Anonymous

Aug 25, 2022

DFS is depth first search and BFS is breadth first search. We use DFS when we know that the solution is far away from the root. We use BFS when we know that the solution node is closer to the root. BFS would work better here because it is a level order traversal.