Single Choice Easy

QWhat is the time complexity of a topological sort algorithm on a directed acyclic graph (DAG) with V vertices and E edges?

ID: #15271 Time Complexity 180 views
Question Info
#15271Q ID
EasyDifficulty
Time ComplexityTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A O(1)
  • B O(log V)
  • C O(V)
  • D O(V + E)
Correct Answer

Explanation

Topological sort is an algorithm used to linearly order the vertices of a directed acyclic graph (DAG) based on their dependencies. It employs depth-first search (DFS) to visit all the vertices, resulting in a time complexity proportional to the sum of the number of vertices (V) and the number of edges (E), denoted as O(V + E).

Share This Question

Challenge a friend or share with your study group.