UCF Computer Science



Title: Sorting songs

Points: 100 points

Submission Due: Sunday July 29, 2007, 11 PM

Cut off date: same as due date. No late submissions !

Objectives:

To implement mergesort.

Description:

In this assignment you will sort songs by title and by artist by implementing the merge sort algorithm covered in lecture. The first line of the input file indicates the number of test cases. Each test case starts with n, the total number of songs for that test case. This is followed by n lines, with each line containing the name of an artist followed by a title. All names and titles are strings with no spaces.

You have to carry out the following tasks:

Design a struct for a song. The struct contains two strings, one for the name of the artist and the other for the title. Once you read the number of songs from the input file, dynamically allocate memory to hold the struct information.

Implement the mergesort algorithm to sort arrays of the struct described above. Use it to sort the songs in alphabetical order by title (let alphabetical order be the order described by strcmp). Generate a list of the items sorted by title.

Next, sort the songs alphabetically by the name of the artists. Print the list of all songs with the name of the artist followed by the corresponding title on a separate line such that artists are arranged in the alphabetical order. If an artist has multiple titles, the name should show up multiple times.

Print an alphabetical list of the artists ( each name to appear only once).

Finally, for each artist sort the titles as well. Print an alphabetical list of artists, and for each artist print the alphabetical order of the titles. Follow the format indicated in the sample output.

Repeat the process for the remaining test cases, if any.

Input Data:

Ask the user for the name of the input file. The user will enter the name of a valid input file.

Sample Input File:

1

8

Augie_March One_Crowded_Hour

Tiger_Army Forever_Fades_Away

Da_Truth Roll_Now

Tiger_Army Afterworld

Augie_March The_Vineyard

Augie_March Brundisium

The_Pipettes Really_That_Bad

The_Pipettes I_Love_You

Sample Output:

Follow the format shown below. Process each test case separately.

What is the name of the data file?

CD.txt

---------------------TEST CASE 1------------------------

Sorted list of titles

1 Afterworld

2 Brundisium

3 Forever_Fades_Away

4 I_Love_You

5 One_Crowded_Hour

6 Really_That_Bad

7 Roll_Now

8 The_Vineyard

Songs Sorted by artist

Augie_March One_Crowded_Hour

Augie_March The_Vineyard

Augie_March Brundisium

Da_Truth Roll_Now

The_Pipettes Really_That_Bad

The_Pipettes I_Love_You

Tiger_Army Forever_Fades_Away

Tiger_Army Afterworld

Alphabetical list of Artists

Augie_March

Da_Truth

The_Pipettes

Tiger_Army

Final List

Augie_March

1. Brundisium

2. One_Crowded_Hour

3. The_Vineyard

Da_Truth

1. Roll_Now

The_Pipettes

1. I_Love_You

2. Really_That_Bad

Tiger_Army

1. Afterworld

2. Forever_Fades_Away

Restrictions:

1. Your source file should begin with comments containing the following information:

/* Name:

PID:

Course:

Assignment title:

Date:

Program compilation: My programs works under gcc on OLYMPUS/ devC++

The code represents my own effort, and I have not copied any part of it from another source.

*/

2. Code should run under gcc on OLYMPUS or under devC++.

Deliverables:

Submit the assignment via WebCT.

Due date: 11 PM, July 29, 2007.

Cut off date: 11 PM, July 29, 2007.

NO LATE SUBMISSIONS WILL BE ACCEPTED !!!

Your code must compile under gcc or cygwin.

It is recommended that you make use of the Olympus account or devC++ for working on the assignment. Save the program as .c if working with devC++.

-----------------------

COP 3502 Summer 2007 -- Programming Assignment #6

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download