Computer Science EngineeringHard

The time complexity of topological sorting of a DAG with V vertices and E edges using DFS is

  1. A. O(V^2 E)
  2. B. O(E log V)
  3. C. O(V log V)
  4. D. O(V + E)

Correct answer: D. O(V + E)

DFS visits each vertex and edge once.

More Algorithms, Data Structures & Programming (ISRO CS) questions

Exams that ask this topic