Michael Kosler, Michael Parsons, Doug Lasater
[email protected], [email protected], [email protected]
02/07/2012
Assignment 2 deals mainly with the testing various sorting functions, specifically selection sort, insertion sort, bubble sort, shell sort,
and radix sort. The user of the program is required to write in a few command line arguments that tell the program:
- which sorting algorithm to use;
- where to get its input source;
- where to insert the sorted output;
In addition to implementing various sorting algorithms, the assignment is trying to show us how different algorithms compare to one another directly.
We are also supposed to see that the algorithms have much different run times based on the size of their input, which gives us a good visualization
of how a run-time function (and asymptotic notation) works in a real world scenario.
We are mainly sorting through arrays of integers, so nothing fancy there.
- Selection Sort:
- Insertion Sort:
- Bubble Sort:
- Shell Sort:
- Radix Sort:
The program is organized into separate classes for each sorting function. For example, insertion sort is encapsulated within its own class, and bubble
sort is encapsulated within its own class. They all inherit from a superclass, sort, which provides a virtual function sort and a protected variable
num_cmps.
In the command line:
cd path/to/files/
make
The input files need to be formatted so that the first line in the file is the size of the array of numbers (to be sorted). Then every number in the
array needs to be added to its own line.
The output file is similar to the input file, except it will only print out the sorted numbers, and not worry about the size of the array.
To be completed
Our program uses inheritance and polymorphism heavily. The main reason we split the program into classes is to give an easier interface to understand.
Every single sort class has a sort function; every single sort class has a num_cmps variable. We used an abstract class as a pseudo-template for the
subclasses. We also gave the user the oppportunity to test the function against their own inputfiles.
To be completed