Question: can someone help me to solve it, please? P2) (25 pts) You have a list of songs S1, S2, S3, ..., Sn that you would
can someone help me to solve it, please?
P2) (25 pts) You have a list of songs S1, S2, S3, ..., Sn that you would like to download onto your MP3 player. The available disk space in our MP3 player would allow you to download all of these songs, but your budget would not. Assume that you can spend no more than D dollars, that the ith song S, costs di dollars, and that di SD. Assume that you want to maximize the number of songs that you download from that list within your D dollar budget. a. (15 pts) Describe a greedy strategy to select what songs to download. b. (10 pts) Write down your greedy algorithm (pseudo code). If you want to sort the data(actually you will), just write : Sort the songs in increasing order of cost or decreasing order of cost. i.e. you do not have to write the actual code for the sort algorithm. (similar to what we did in the class)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
