Divide and Conquer · Algorithms
6 questions · asked in 5 of 27 years (2000–2026)
MCQ 4 · NAT 21-mark 4 · 2-mark 2
2000Questions per year2026
Questions 6–6 of 6
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.
Answer: (A)
Let be the number of vertices and the number of edges.
1. Bellman-Ford: it runs rounds, and each round relaxes all edges, so (C).
2. Kruskal: sorting the edges costs , which is because ; the union-find steps cost no more. So (A).
3. Floyd-Warshall: three nested loops over all vertices, so (B).
4. Topological sorting: one DFS (or repeated removal of zero in-degree vertices) visits each vertex and edge once, so (D).
So 1 to C, 2 to A, 3 to B, 4 to D.
Answer: (A)
1. Bellman-Ford: it runs rounds, and each round relaxes all edges, so (C).
2. Kruskal: sorting the edges costs , which is because ; the union-find steps cost no more. So (A).
3. Floyd-Warshall: three nested loops over all vertices, so (B).
4. Topological sorting: one DFS (or repeated removal of zero in-degree vertices) visits each vertex and edge once, so (D).
So 1 to C, 2 to A, 3 to B, 4 to D.
Answer: (A)
Keep practising