Graph Theory37 sections · 1633 units
Open in CourseQuiz: 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?
- A.Same. Both are
- B.DFS is faster because it does not use a queue
- C.DFS with backtracking is exponential, while BFS is
- D.DFS is slower by a constant factor only