Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

Question 2 (5 points) Suppose that you have a collection of magnets of m different lengths: Ll > 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: L] > 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 30, 7, 1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Time Series Databases New Ways To Store And Access Data

Authors: Ted Dunning, Ellen Friedman

1st Edition

1491914726, 978-1491914724

More Books

Students also viewed these Databases questions

Question

Explain the function and purpose of the Job Level Table.

Answered: 1 week ago