510 views
3 votes
3 votes
Farmer Raju has been elected mayor of his town!! One of his campaign promises was to bring internet connectivity to all farms in the area. He need someone help, of course.

Raju ordered a high speed connection for his farm and is going to share his connectivity with other farmers. To minimize cost, he wants to lay the minimum amount of optical fiber to connect his farm to all the other farms. Given a list f how much fiber it takes to connect each pair of farms, problem is to find out minimum amount of fiber needed to connect them all together. Each farm must connect to some other farm such that a packet can flow from any one farm to any other farm.

1 Answer

Best answer
4 votes
4 votes
Consider the farms as the vertices of a graph.

Let us assume that to join the villages V1 and V2 by an optical fibre needs f fibres.

So, in our graph we join the vertices V1 and V2 by an edge and put the weight f on it.

Now,apply kruskal algorithm on the graph to find the minimum weight spanning tree.

The summation of the edge weights of the minimum spanning tree is the reqd minimum number of fibres needed to connect the village with optical fibre.
selected by

Related questions

0 votes
0 votes
3 answers
1
iarnav asked Apr 29, 2018
1,504 views
Question 1) The shortest-path tree computed by Dijkstra's algorithm is necessarily an MST?Question2 ) Prim's algorithm works with negative weighted edges?