Menu

[Solved]Q2 Rst Line Gives Integer K Second Line Separator Character Contained Song Composer String Q37100737

For Q2, the first line gives the integer k, and the second line aseparator character that is not contained in any of the song orcomposer strings. The subsequent lines give the song data, withfields separated by the separator character.

sample input

3 Pink Frost&Phillipps, Martin&234933 Se quel guerrier io fossi&Puccini, Giacomo&297539 Non piu andrai&Mozart&234933 Mappari

sample output

Se quel guerrier io fossi&Puccini, Giacomo&297539 Mappari tuttamor&Flotow, F&252905 Non piu andrai.&M0%art&234933

2. Top songs (50 marks) Devise an algorithm and implement it in a program to solve the following problem, similar to one oftecan use Java or Python!!!!!

3 Pink Frost&Phillipps, Martin&234933 Se quel guerrier io fossi&Puccini, Giacomo&297539 Non piu andrai&Mozart&234933 M’appari tutt’amor&Flotow, F&252905 Se quel guerrier io fossi&Puccini, Giacomo&297539 M’appari tutt’amor&Flotow, F&252905 Non piu andrai.&M0%art&234933 2. Top songs (50 marks) 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 k 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 order on ASCII characters. You should first make sure that your algorithm and implementation are correct! It is up to you to come up with test cases and the corresponding correct output. Usually, if a program contains an error, this can be detected on a small test case. You are allowed to share test cases with the class via the class forum. Next you should consider efficiency. Remember that the test cases may use any value of k and n. Please see below for information on input and output formats. Show transcribed image text 3 Pink Frost&Phillipps, Martin&234933 Se quel guerrier io fossi&Puccini, Giacomo&297539 Non piu andrai&Mozart&234933 M’appari tutt’amor&Flotow, F&252905
Se quel guerrier io fossi&Puccini, Giacomo&297539 M’appari tutt’amor&Flotow, F&252905 Non piu andrai.&M0%art&234933
2. Top songs (50 marks) 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

Expert Answer


Answer to For Q2, the first line gives the integer k, and the second line a separator character that is not contained in any of t… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *