Assignment 6

CSIS 10B
Assignment 6 Sorting
Due: next Wed
In Class Demo (0 points):
1) Sorting Array of Strings:
a. O(n2): Bubble, Selection, Insertion
b. O(n log n ) Mergesort, Quicksort
2) Using Comparators
a. Caseless String Sort
b. WordFreq sort by word or frequency, ascending or descending
3) Sorting Vectors
Assignment (10 points) Do either Basic or Advanced.
This assignment is a continuation of the Student database problem in assignment 4 although you may
start from scratch to accomplish the following:
1) Load the data in Student100.txt into either a Vector of Student or a Vector of Vector of
Association as you did in assignment 4
(The column headings for the file are: ID, FirstName, LastName, GPA)
2) Use Comparators to allow the user to sort the database by either: ID, GPA, or name (make
sure students with two last names are sorted in order of their first names) and in ascending
or descending order
3) At the bottom of your solution, add comments for your answers to Self-Check problems 6.2,
6.3, 6.5
4) Add a recursive version of selection sort to your solution to 2) and test your sort on a vector
of random integers and/or your database as well. Read problems 6.16 and 6.17 first, and the
solution to 6.17 found on page 466.
Advanced: File Sort
Create a program that sorts a randomly shuffled unique list of integers between 0 and 1 million but only
uses 1000 32 bit integers of space. (Problem 6.20). You’ll first need to create the file you will be sorting,
in a separate program, using an array of integers that you shuffle by doing, say, a million swaps between
random cell numbers. Once you have the file written, your sort algorithm is only allowed to store in
program memory 1000 values at a time (not including support variables like Scanners and counters, etc)
in constructing the sorted output file.