Question: Develop a greedy algorithm to solve the following problem using the staying ahead pattern: You are compiling a CD for a party. There are n
Develop a greedy algorithm to solve the following problem using the "staying ahead" pattern:
"You are compiling a CD for a party. There are n songs that you are considering including on the CD. Song i has a length li and popularity pi. The CD can have a maximum length of L. How much of each song should be included on the CD to maximize the total popularity of the CD, without exceeding the CD's capacity? You may include fractions of songs. (If you include half of song i, it would contribute a popularity of pi/2 to the CD)"
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
