Graph Theory37 sections · 1633 units
Open in Course

Quiz: BFS vs DFS for Shortest Path

Knowledge check

Check Your Understanding

You need to find the shortest path in an unweighted grid from top-left to bottom-right. You implement DFS with backtracking to find all paths and return the shortest. What is the time complexity compared to BFS?

  1. A.Same. Both are O(V+E)O(V + E)
  2. B.DFS is faster because it does not use a queue
  3. C.DFS with backtracking is exponential, while BFS is O(V+E)O(V + E)
  4. D.DFS is slower by a constant factor only
Start the roadmap to answer the quizzes and solve the challenges