Question: Problem 2 : 8 * * 2 = 1 6 p t s A music streaming service manages playlists and user interactions. They need to

Problem 2:
8**2=16pts
A music streaming service manages playlists and user interactions. They need to perform specific operations on their data structures to enhance user experience.
Define a recursive function playlist-duration that takes two lists: songLengths and repeatCounts. The function should return a new list where each element is the total duration of the corresponding song after considering how many times it is repeated. If one list is shorter, assume the missing elements in repeatCounts are 1, and missing elements in songLengths are 0.
\table[[Sample Input: songLengths,Sample Input: repeatCounts,Sample Output],['(200180240),'(231),'(400540240)],['(150220),,(3),'(450220)]]
Define a recursive function cumulative-playlist-duration, which takes a list of song durations and returns a new list where each element represents the cumulative duration up to that point. If the cumulative sum at any point exceeds 1000, it should stop adding further songs to the playlist and ensure the last element in the list is 1000. You may use a helper function to handle the recursion.
\table[[Sample Input: songDurations,Sample Output],['(200300400200),'(2005009001000)],['(500600700),,(5001000)],[,(250250500300),(2505001000)],['(800200100),'(8001000)],[,(1001100),,(1000)]]
Problem 2 : 8 * * 2 = 1 6 p t s A music streaming

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 Programming Questions!