🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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?

  1. A.Two nodes have no edges
  2. B.The graph has a cycle, so the remaining nodes never reached in-degree 0
  3. C.The queue was too small
  4. 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 →