Questions: Topological Sort

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

You run a topological sort algorithm on a directed graph and observe that Kahn's algorithm terminates with only 4 of the 6 nodes placed in the output. What can you conclude?

AThe graph has a valid topological ordering, but the algorithm made an error
BThe graph contains a cycle involving the 2 nodes not in the output
CThe graph is disconnected and the 2 missing nodes are in a separate component
DThe algorithm needs to be restarted from a different source node
Question 2 Multiple Choice

For the dependency graph A → C, B → C, B → D, A → D, which of the following is a valid topological ordering?

AC, D, A, B
BA, C, B, D
CA, B, C, D
DB, D, A, C
Question 3 True / False

A DAG with 5 nodes can have more than one valid topological ordering.

TTrue
FFalse
Question 4 True / False

A graph with a directed cycle has multiple valid topological orderings, since you can start the cycle at different points.

TTrue
FFalse
Question 5 Short Answer

How does Kahn's algorithm naturally detect that a graph contains a cycle, without any explicit cycle-checking code?

Think about your answer, then reveal below.