
CS 302 Assignment 3:
Counting the Number of Comparisons of a Sorting Algorithm
Due date: Thursday, September 15, 2011, midnight.
All programming assignments must be
submitted electronically.
Submit them to the graduate assistant,
Lucas Bang, by email at
bang"at"unlv"dot"nevada"dot"edu
on or before the due date.
Read the instructions on how to submit programs.
Write a program which
-
Reads real numbers from a file into an array of size no more than 1000,
and reports the size of that array.
-
Sorts the array using mergesort.
-
Sorts the array using quickesort.
-
Counts the number of comparisons for each of the two sorting
algorithms, and reports that number.
Use the following four files to test your program:
a small file.
a large file.
a file that is "almost" sorted..
another file that is almost sorted.
another file that will cause you serious
trouble if you are not careful.