33 33 votes In the following table, the left column contains the names of standard graph algorithms and the right column contains the time complexities of the algorithms. Match each algorithm with its time complexity.$$\begin{array}{|ll|ll|}\hline \text{1.} & \text{Bellman-Ford algorithm} & \text{A:} & \text{$O(m\log n)$} \\\hline \text{2.} & \text{Kruskal’s algorithm} & \text{B:}& \text{$O(n^3)$} \\\hline \text{3.}& \text{Floyd-Warshall algorithm} & \text{C:} & \text{$O(nm)$} \\\hline \text{4.} & \text{Topological sorting} &\text{D:} & \text{$O(n+m)$} \\\hline \end{array}$$ $\text{1→ C, 2 → A, 3 → B, 4 → D}$ $\text{1→ B, 2 → D, 3 → C, 4 → A}$ $\text{1→ C, 2 → D, 3 → A, 4 → B}$ $\text{1→ B, 2 → A, 3 → C, 4 → D}$ Algorithms gateit-2005 algorithms graph-algorithms match-the-following easy + – Ishrat Jahan 8.4k views answer comment Share Follow Print See 1 comment 1 1 comment reply Nalinj commented Mar 12, 2025 reply Follow flag this classifies under theory/meemory based question? 0 0 replyShare Please log in or register to add a comment.
Best answer 44 44 votes Bellman-Ford algorithm $\implies \text {option} (C)$, $O (nm)$. Assuming $n$ as edges , $m$ as vertices, for every vertex we relax all edges. $m*n$ , $O(mn)$. Kruskal’s algorithm $\implies$ Remaining Option $(A)$ : $O ( m \log n)$. Floyd-Warshall algorithm $\implies$ option $(B)$, Dynamic Programming Algo, $O(N^3)$. Topological sorting $\implies \text {option} (D)$, boils down to DFS, $O(V+E)$. Answer (A). Akash Kanase answered Dec 18, 2015 • edited Jun 24, 2018 by Shikha Mallick Akash Kanase comment Share Follow See all 2 Comments 2 2 Comments reply Venky8 commented Dec 17, 2021 reply Follow flag $\text{Kruskal's algorithm using union-find:} \\ \text{Time Complexity = Time taken for sorting edges + Picking edges one by one} \\ \text{from sorted edges so that it does not form a cycle} \\ = O(mlogm) + O(1) * O(m) \\ ( \because \text{ O(1) to check cycle using union find) } \\ = O(mlogm) + O(m) \\ = O(m log n^2) \left (\text {As m} = O(n^{2}) \right ) \\ = O(2mlogn) \\ = O(mlogn)$ 7 7 replyShare pavansan commented Jan 2, 2025 reply Follow flag confused and put option d 0 0 replyShare Please log in or register to add a comment.
4 4 votes Option a you can get it from any standard book Bhagirathi answered Nov 8, 2014 Bhagirathi comment Share Follow 0 reply Please log in or register to add a comment.