Question: (Algorithm question) I can't solve it as Greedy algorithm and dynamic programming. Could anyone explain it for me? Thank you. 2. You are planning to

(Algorithm question) I can't solve it as Greedy algorithm and dynamic programming. Could anyone explain it for me? Thank you.

(Algorithm question) I can't solve it as Greedy algorithm and dynamic programming.

2. You are planning to buy a set of fancy lenses for your DSLR camera. The camera store has n lenses, where lens i has a cost C and works over a range of focal lengths (si, fi). (If you're unfamiliar with cameras, you can think of focal length as zoom level.) You would like to buy a set of lenses that covers a wide range [L, H) of focal lengths, so every length in this range is supported by at least one of your lenses. You may assume all the parameters are integers. (a) Give an O(n(H L)) time dynamic programming algorithm to find the cheapest set of lenses that covers the entire range [L, H). Recall that you should: Define a subproblem, which you describe in English. Give a recurrence to solve the subproblem. Show that the recurrence is correct. Describe how to solve the problem quickly, and analyze the resulting running time. (b) The camera store is now having an amazing sale, where every lens has the same cost ci = $100! Give a simple greedy algorithm that finds the answer in O(n log n) time. (c) (Optional): Show how to solve part (a) in O(n log n) time. 2. You are planning to buy a set of fancy lenses for your DSLR camera. The camera store has n lenses, where lens i has a cost C and works over a range of focal lengths (si, fi). (If you're unfamiliar with cameras, you can think of focal length as zoom level.) You would like to buy a set of lenses that covers a wide range [L, H) of focal lengths, so every length in this range is supported by at least one of your lenses. You may assume all the parameters are integers. (a) Give an O(n(H L)) time dynamic programming algorithm to find the cheapest set of lenses that covers the entire range [L, H). Recall that you should: Define a subproblem, which you describe in English. Give a recurrence to solve the subproblem. Show that the recurrence is correct. Describe how to solve the problem quickly, and analyze the resulting running time. (b) The camera store is now having an amazing sale, where every lens has the same cost ci = $100! Give a simple greedy algorithm that finds the answer in O(n log n) time. (c) (Optional): Show how to solve part (a) in O(n log n) time

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!