UGC-NET Dec 2012 · Asymptotic Analysis & Recurrences
MCQ · 2 marks · Problem PROG-DIVC-0011
The time complexities of some standard graph algorithms are given. Match each algorithm with its time complexity ? ($n$ and $m$ are no. of nodes and edges respectively)
$\begin{array}{clcl} \text{a.} & \text{Bellman Ford algorithm} & \text{i.} & O(m\log n) \\ \text{b.} & \text{Kruskals algorithm} & \text{ii.} & O(n^3) \\ \text{c.} & \text{Floyd Warshall algorithm } & \text{iii.} & O(mn) \\ \text{d.} & \text{Topological sorting} & \text{iv.} & O(n+m) \\ \end{array}$
$\textbf{Codes :}$
Show the worked solutionStandard running times (\(n\) vertices, \(m\) edges):a. Bellman-Ford relaxes all \(m\) edges \(n-1\) times: \(O(mn)\), so a-iii.b. Kruskal is dominated by sorting the edges: \(O(m\log m)=O(m\log n)\), so b-i.c. Floyd-Warshall has three nested loops over the vertices: \(O(n^3)\), so c-ii.d. Topological sort is one DFS: \(O(n+m)\), so d-iv.The code a-iii, b-i, c-ii, d-iv is option A.Answer: A
GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com