What is the difference between BFS and DFS?
What is the difference between BFS and DFS?
Approach: Compare search order and data structures used.
Breadth-First Search (BFS) explores all neighbors at the current depth before moving deeper (uses a queue). Depth-First Search (DFS) explores as far as possible along each branch before backtracking (uses a stack or recursion).
Follow-up: Which one finds the shortest path in an unweighted graph?
Key concepts: queue, stack, shortest path.