Quiz 2 - DFS vs BFS
You are analyzing a directed graph that represents a complex network of dependencies between software modules. You need to ensure the system is free of circular dependencies and find the minimum number of steps to reach a specific module from the source.
Based on the properties of Breadth-First Search (BFS) and Depth-First Search (DFS) presented in the course, which statement correctly identifies the best approach?
A) BFS should be used to find the shortest path (minimum steps) because it provides parent links with a distance guarantee, while DFS is required to detect circular dependencies by identifying "backward edges."
B) DFS should be used to find the shortest path because its "finishing times" represent the most efficient order, while BFS is the only tool capable of "edge classification" to find cycles.
C) In this directed graph, both BFS and DFS will naturally identify "forward" and "cross" edges, making them equally effective for topological sorting and cycle detection.
D) BFS is preferred for detecting cycles in undirected graphs because it lacks "forward edges," whereas DFS is preferred for shortest paths because it uses a stack to explore deep dependencies first.
Nice question. I took it. Next time, don't forget to add "Original idea by:" and your name in the end.
ResponderExcluir