Question: Question 2 (5 points) Suppose that you have a collection of magnets of m different lengths: Li > L2 > ... > Lm (You can

 Question 2 (5 points) Suppose that you have a collection of

Question 2 (5 points) Suppose that you have a collection of magnets of m different lengths: Li > L2 > ... > Lm (You can assume that you have an unlimited number of magnets of each of these lengths.) You would like to connect a series of these magnets, end-to-end, to create a total length of n. For example, if you have magnets of length 20, 5 and 1, you could create a total length of 72 by using twelve magnets of length 5 and twelve magnets of length 1. Another solution would be to use two magnets of length 20, six magnets of length 5, and two magnets of length 1. An optimal solution uses the *smallest* number of magnets possible to create a total length of n. (a) Describe a greedy approach to solving this problem. In your solution, do not refer to the specific lengths (20, 5, 1) mentioned above, but refer instead to the general lengths: Li > L2 > > Lm (b) Use an example to demonstrate that your greedy algorithm is *not guaranteed to be optimal if the lengths of magnets available are 15, 6, 1. Enter your answers in the box below or use the 'Add a File' button to submit a file

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!