Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started