1.

Most Efficient Time Complexity of Topological Sorting is? (V – number of vertices, E – number of edges)(a) O(V + E)(b) O(V)(c) O(E)(d) O(V*E)The question was asked in a job interview.This intriguing question comes from Topological Sort topic in division Miscellaneous of Data Structures & Algorithms II

Answer»

The correct choice is (a) O(V + E)

Explanation: The TOPOLOGICAL sort ALGORITHM has complexity same as Depth FIRST SEARCH. So, DFS has a complexity O(V+E).



Discussion

No Comment Found

Related InterviewSolutions