# GATE | GATE-IT-2004 | Question 56

Consider the undirected graph below:

Using Prim’s algorithm to construct a minimum spanning tree starting with node A, which one of the following sequences of edges represents a possible order in which the edges would be added to construct the minimum spanning tree?

**(A)** (E, G), (C, F), (F, G), (A, D), (A, B), (A, C)

**(B)** (A, D), (A, B), (A, C), (C, F), (G, E), (F, G)

**(C)** (A, B), (A, D), (D, F), (F, G), (G, E), (F, C)

**(D)** (A, D), (A, B), (D, F), (F, C), (F, G), (G, E)

**Answer:** **(D)**

**Explanation:** A**. False **The idea behind Prim’s algorithm is to construct a spanning tree – **means all vertices must be connected **but here vertices are disconnected

B. **False **The idea behind Prim’s algorithm is to construct a spanning tree – **means all vertices must be connected **but here vertices are disconnected

C.** False. **Prim’s is a **greedy algorithm** and At every step, it considers all the edges that connect the two sets, and picks the minimum weight edge from these edges. In this option weight of AB<AD so must be picked up first.

D.**TRUE.**

**Therefore, Answer is D**

Prim’s algorithm is also a Greedy algorithm. It starts with an empty spanning tree. The idea is to maintain two sets of vertices. The first set contains the vertices already included in the MST, the other set contains the vertices not yet included. At every step, it considers all the edges that connect the two sets, and picks the minimum weight edge from these edges. After picking the edge, it moves the other endpoint of the edge to the set containing MST.

Read more at: https://www.geeksforgeeks.org/greedy-algorithms-set-5-prims-minimum-spanning-tree-mst-2/

Quiz of this Question

Please comment below if you find anything wrong in the above post

## Recommended Posts:

- GATE | GATE-IT-2004 | Question 32
- GATE | GATE-IT-2004 | Question 83
- GATE | GATE-IT-2004 | Question 82
- GATE | GATE-IT-2004 | Question 81
- GATE | GATE-IT-2004 | Question 80
- GATE | GATE-IT-2004 | Question 79
- GATE | GATE-IT-2004 | Question 78
- GATE | GATE-IT-2004 | Question 77
- GATE | GATE-IT-2004 | Question 76
- GATE | GATE-IT-2004 | Question 75
- GATE | GATE-IT-2004 | Question 84
- GATE | GATE-IT-2004 | Question 85
- GATE | GATE-IT-2004 | Question 86
- GATE | GATE-IT-2004 | Question 90
- GATE | GATE-IT-2004 | Question 89
- GATE | GATE-IT-2004 | Question 88
- GATE | GATE-IT-2004 | Question 87
- GATE | GATE-IT-2004 | Question 74
- GATE | GATE-IT-2004 | Question 27
- GATE | GATE-IT-2004 | Question 14