What is the primary difference between BFS and DFS in graph traversal?
-
BFS uses a stack, while DFS uses a queue.
-
BFS explores all neighbors at the present depth before moving on, while DFS explores as far as possible along a branch.
-
BFS is faster than DFS in all cases.
-
DFS is used for finding the shortest path, while BFS is not.