subject

Given n ropes of different lengths, we need to connect these ropes into one rope. We can connect only 2 ropes at a time. The cost required to connect 2 ropes is equal to sum of their lengths. The length of this connected rope is also equal to the sum of their lengths. This process is repeated until n ropes are connected into a single rope.
Find the min possible cost required to connect all ropes.
For example: Suppose you have three ropes with lengths 2, 5, and 8. If you chose first to connect the length 5 and 8 ropes, then connect the length 2 and 13 ropes, the total cost would be (5 + 8) + (13 + 2) = 28. However, if you first chose to connect the length 2 and 5 ropes, then the length 7 and 8 ropes, the total cost would be (2 + 5) + (7 + 8) = 22 (which happens to be optimal).

(a) Specify with pseudo-code a greedy algorithm to connect the ropes with minimum cost.
(b) Prove your algorithm always finds the least cost solution if the lengths of the ropes are distinct.
(c) Analyze your algorithm's complexity.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 03:00
State 7 common key's for every keyboard
Answers: 1
question
Computers and Technology, 23.06.2019 11:30
Which excel file extension stores automated steps for repetitive tasks?
Answers: 1
question
Computers and Technology, 24.06.2019 14:00
In the microsoft® access® and microsoft excel® programs, the ribbon contains tabs that are divided into with like tools in them. parts groups containers bunches
Answers: 1
question
Computers and Technology, 24.06.2019 21:30
Along what line of action can the camera move to follow the movement of actors for screen direction? a. along a 90-degree arcb. along a 120-degree arcc. along a 180-degree arcd. along a 360-degree arc
Answers: 1
You know the right answer?
Given n ropes of different lengths, we need to connect these ropes into one rope. We can connect onl...
Questions
question
English, 14.11.2020 23:10
question
Arts, 14.11.2020 23:10
Questions on the website: 13722363