Question: Devise an algorithm and implement it in a program to solve the following problem, similar to one often faced by an MP3 player. For our
Devise an algorithm and implement it in a program to solve the following problem, similar to one often faced by an MP3 player. For our purposes, a song consists of the following data fields: title (a nonempty ASCII string), composer (a (possibly empty) ASCII string), running time (a positive integer). Input consists of n songs and an integer with 1 〈 k 〈 n. Your program must find the songs with longest running times, and output these songs in descending order of length of song. If songs have the same running time, then we use lexicographic order on the title, and then on the composer, to get a total ordering. The lexicographic order comes from the usual order on ASCII characters Instruction: the first line gives the integer k, and the second line a separator character that is not contained in any of the song or composer strings. The sub sequence lines give the song data, with fields separated by the separator character
Step by Step Solution
3.48 Rating (158 Votes )
There are 3 Steps involved in it
To solve the problem of finding the k longest running songs from a given list and ordering them by specific criteria we need to devise an algorithm an... View full answer
Get step-by-step solutions from verified subject matter experts
