0% found this document useful (0 votes)
35 views1 page

DAA Assignment-2april

The document discusses Prim's algorithm for constructing a minimum spanning tree on an undirected graph starting at node A. It provides four possible sequences of edges that could be added and asks which one represents a valid ordering according to Prim's algorithm. The answer is option D and an explanation is provided that it is the correct ordering since Prim's is a greedy algorithm that always picks the minimum weight edge at each step to connect the sets.

Uploaded by

Abhinav arora
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views1 page

DAA Assignment-2april

The document discusses Prim's algorithm for constructing a minimum spanning tree on an undirected graph starting at node A. It provides four possible sequences of edges that could be added and asks which one represents a valid ordering according to Prim's algorithm. The answer is option D and an explanation is provided that it is the correct ordering since Prim's is a greedy algorithm that always picks the minimum weight edge at each step to connect the sets.

Uploaded by

Abhinav arora
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

ASSIGNMENT

Q. Consider the undirected graph:

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? Give the correct option with
explaination.
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: Option (D)

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 - 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.

You might also like