Question

Which algorithm is a greedy algorithm used to find the Minimum Spanning Tree (MS

  • T of a graph by repeatedly adding the smallest weight edge that connects two disconnected components?
A Dijkstra's Algorithm Correct Answer Incorrect Answer
B Prim's Algorithm Correct Answer Incorrect Answer
C Kruskal's Algorithm Correct Answer Incorrect Answer
D Bellman-Ford Algorithm Correct Answer Incorrect Answer
E Floyd-Warshall Algorithm Correct Answer Incorrect Answer

Solution

Kruskal's Algorithm is a greedy algorithm for finding an MST. It sorts all the edges in non-decreasing order of their weights and then adds edges one by one to the MST if they do not form a cycle with the already added edges. Prim's Algorithm is also greedy but builds the MST by growing a single component.

Practice Next
ask-question