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, 22.06.2019 14:30
Create a pseudocode design to prompt a student for their student id and the titles of the three classes they want to add. the solution should display the student’s id and a total bill. • bill a student using the following rules: o students can only add up to 3 classes at a time.
Answers: 3
question
Computers and Technology, 23.06.2019 09:10
Effective character encoding requires standardized code. compatible browsers. common languages. identical operating systems.
Answers: 1
question
Computers and Technology, 24.06.2019 10:30
This device directs network traffic. bridge hub nic repeater router switch
Answers: 3
question
Computers and Technology, 24.06.2019 12:50
What percentage of teens plays video games? a.97% b.100% c.74% d.50%
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
Mathematics, 01.12.2021 01:00
question
History, 01.12.2021 01:00