retagged by
5,186 views
22 votes
22 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}$$

  1. $\text{1→ C, 2 → A, 3 → B, 4 → D}$
  2. $\text{1→ B, 2 → D, 3 → C, 4 → A}$
  3. $\text{1→ C, 2 → D, 3 → A, 4 → B}$
  4. $\text{1→ B, 2 → A, 3 → C, 4 → D}$
retagged by

2 Answers

Best answer
32 votes
32 votes
  1. 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)$.
  2. Kruskal’s algorithm $\implies$ Remaining Option $(A)$ :  $O ( m \log n)$.
  3. Floyd-Warshall algorithm $\implies$ option $(B)$, Dynamic Programming Algo, $O(N^3)$.
  4. Topological sorting $\implies \text {option} (D)$,  boils down to DFS, $O(V+E)$.

Answer (A).

edited by
Answer:

Related questions

65 votes
65 votes
12 answers
3
Ishrat Jahan asked Nov 3, 2014
17,790 views
In a depth-first traversal of a graph $G$ with $n$ vertices, $k$ edges are marked as tree edges. The number of connected components in $G$ is$k$$k+1$$n-k-1$$n-k$