retagged by
8,444 views
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}$$

  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}$

2 Answers

Best answer
44 44 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:
Position:
Show:

Related questions

48 48 votes
8 answers 8 answers
12.8k
12.8k views
Ishrat Jahan asked Nov 3, 2014
12,830 views
A sink in a directed graph is a vertex i such that there is an edge from every vertex $j \neq i$ to $i$ and there is no edge from $i$ to any other vertex. A directed grap...
48 48 votes
5 answers 5 answers
15.8k
15.8k views
Ishrat Jahan asked Nov 3, 2014
15,755 views
A sink in a directed graph is a vertex i such that there is an edge from every vertex $j \neq i$ to $i$ and there is no edge from $i$ to any other vertex. A directed grap...
93 93 votes
17 answers 17 answers
29.4k
29.4k views
Ishrat Jahan asked Nov 3, 2014
29,394 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$
40 40 votes
6 answers 6 answers
14.6k
14.6k views
Ishrat Jahan asked Nov 3, 2014
14,592 views
Let $T(n)$ be a function defined by the recurrence$T(n) = 2T(n/2) + \sqrt n$ for $n \geq 2$ and$T(1) = 1$Which of the following statements is TRUE?$T(n) = \Theta(\log n)$...