🎙 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 8 of 15

What is the time complexity of topological sort for V nodes and E edges?

What is the time complexity of topological sort for V nodes and E edges?

  1. A.O(V²) always
  2. B.O(E log V)
  3. C.O(V + E)
  4. D.O(V · E)
Answer & explanation

Correct answer: O(V + E)

Each node is processed once and each edge is looked at once, in both Kahn's and DFS.

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 →