← 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?
- A.O(V²) always
- B.O(E log V)
- C.O(V + E)
- 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 →