← Quiz: Topological Sort: all 15 questions
Quiz: Topological Sort · Question 4 of 15
Kahn's algorithm finishes with 4 nodes in the order, but the graph has 6 nodes. What does this mean?
Kahn's algorithm finishes with 4 nodes in the order, but the graph has 6 nodes. What does this mean?
- A.Two nodes have no edges
- B.The graph has a cycle, so the remaining nodes never reached in-degree 0
- C.The queue was too small
- D.The order is still valid; add the 2 nodes at the end
Answer & explanation
Correct answer: The graph has a cycle, so the remaining nodes never reached in-degree 0
Nodes in or behind a cycle always keep at least one unfinished prerequisite.
Can you get the rest right without peeking?
Take the timed Quiz: Topological Sort quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →