Questions: Depth-First Search: Implementation and Applications

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

While running DFS on a directed graph, you encounter an edge from node u to node v, where v has already been discovered but not yet finished. What does this indicate?

AA cross edge — v is in a different DFS tree and was finished in a previous call
BA forward edge — v is a descendant of u that was already visited
CA back edge — v is an ancestor of u on the current DFS path, proving a cycle exists
DA tree edge — v is being discovered for the first time through u
Question 2 Multiple Choice

After running DFS on a DAG with 5 nodes, finish times are: A=8, B=4, C=6, D=2, E=10. Which is the valid topological ordering?

AA, B, C, D, E (alphabetical order)
BE, A, C, B, D (reverse finish time order)
CD, B, A, C, E (ascending finish time order)
DD, B, C, A, E (discovery time order)
Question 3 True / False

If node B's discovery-to-finish interval falls entirely within node A's discovery-to-finish interval in a DFS, then B is a descendant of A in the DFS tree.

TTrue
FFalse
Question 4 True / False

In an undirected graph, any edge discovered during DFS that leads to an already-visited node (other than the direct parent) indicates a cycle.

TTrue
FFalse
Question 5 Short Answer

Why does reversing the finish-time ordering of DFS produce a valid topological sort of a DAG? What property of DFS makes this work?

Think about your answer, then reveal below.