Pick the fix
Which question calls for BFS rather than DFS?
Choose an answer, then open Show answer below to check it.
Show answer
Answer: A The fewest moves for a knight between two squares
Right: every move costs the same, so layer order gives the minimum.
Equal-cost moves plus a 'fewest' question is the signal for breadth-first search.
Why not the others?
- B Whether a dependency graph has a loop. That is a DFS job with three states.
- C Listing every subset of a set. That is backtracking, a form of DFS.