38 38 votes 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? $\text{(E, G), (C, F), (F, G), (A, D), (A, B), (A, C)}$ $\text{(A, D), (A, B), (A, C), (C, F), (G, E), (F, G)}$ $\text{(A, B), (A, D), (D, F), (F, G), (G, E), (F, C)}$ $\text{(A, D), (A, B), (D, F), (F, C), (F, G), (G, E)}$ Algorithms gateit-2004 algorithms graph-algorithms normal prims-algorithm + – Ishrat Jahan 21.6k views answer comment Share Follow Print See all 5 Comments 5 5 Comments reply Show 2 previous comments SilentClimber commented Jan 4, 2024 reply Follow flag $Ans: D$ 5 5 replyShare ritiksri8 commented Mar 21, 2024 reply Follow flag Answer will be (D) in this case as option B fails to make graph connected. 1 1 replyShare mayanksinghchandel commented Dec 5, 2025 reply Follow flag no. if we start from vertex B then AB,AD is the only correct order. so no problem in these 2 atleast. 0 0 replyShare Please log in or register to add a comment.
Best answer 43 43 votes Answer is D. $A$ and $B$ produce disconnected components with the GIVEN order in options which is NEVER allowed by prims's algorithm. $C$ produces connected component every instant a new edge is added BUT when first vertex is chosen(first vertex is chosen randomly) first edge must be the minimum weight edge that is chosen . Therefore, $(A,D)$ MUST be chosen BEFORE $(A,B)$. Therefore, $C$ is FALSE. Sandeep_Uniyal answered Jan 17, 2015 • edited Jun 12, 2018 by Milicevic3306 Sandeep_Uniyal comment Share Follow See all 2 Comments 2 2 Comments reply junk_mayavi commented Nov 4, 2017 reply Follow flag while extracting from min heap, if two nodes comes with same key value, which one to choose ? what i understood is , heap sort is never in-place and we can't predict which min key node appears as root. in that case, we need to try with both the min key values, isn't it ? 1 1 replyShare chirudeepnamini commented Oct 14, 2019 reply Follow flag I think the correct reason for eliminating option c would be "After selecting DF, we should select FC(having weight 4) but we are selecting FG(having weight 5) which is not the minimum". 9 9 replyShare Please log in or register to add a comment.
10 10 votes There are two correct sequences i) (A, D), (A, B), (A, C), (C, F), (F, G), (G, E) (not given in the options) ii) (A, D), (A, B), (D, F), (F, C), (F, G), (G, E) Option- D Sourav Basu answered Dec 21, 2017 Sourav Basu comment Share Follow See all 5 Comments 5 5 Comments reply Show 2 previous comments ankit3009 commented Jan 10, 2021 reply Follow flag how disconnected graph is created in b? it seems correct to me can anyone please explain. 0 0 replyShare aashish1406 commented Jul 26, 2023 reply Follow flag 1 st sequence is wrong bcoz it forms cycle 0 0 replyShare sitikant commented Aug 27, 2023 reply Follow flag The option B sequence should end with (F,G), (G,E) not the other way. That's why it is false. 0 0 replyShare Please log in or register to add a comment.
1 1 vote According to Prim's Algorithms Correct Answer is D Anand Maurya answered Jun 21, 2019 Anand Maurya comment Share Follow 0 reply Please log in or register to add a comment.
0 0 votes Here 2 different Answers are possible . in the first image we visited vertex $C$ firstly before vertex $F$ then we get the answer which does not match with anyone of them and this is wrong answer bcoz it makes cycle iin the second image we visited vertex $F $ firstly before vertex $C$ then we get the answer which does match with option D so the final answer is option D aashish1406 answered Jul 26, 2023 • edited Jul 26, 2023 by aashish1406 aashish1406 comment Share Follow 0 reply Please log in or register to add a comment.