
CS 302 Assignment 5:
Counting the Number of Comparisons of a Sorting Algorithm (Part 3)
Due date: Tuesday, October 11, 2011, midnight.
All programming assignments must be
submitted electronically.
Submit them to the graduate assistant,
Lucas Bang, by email on or before the due date.
Your email must come from your engineering college (or computer science
or computer engineering) account.
Your program must compile
on either bobby or in the lab (TBE B361).
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 same array using heapsort.
-
Counts the number of comparisons for each file and reports that number.
-
You may work this assignment by starting with the code that you wrote
for Assignment 3 and modifying it appropriately.
-
You must use an array implementation
of heapsort, such as the one I gave in class.
-
In a separate document, compare the number of comparisons for each
of the five input files below with the number of comparisons used by
mergesort to sort the same file.
Use the following five files to test your program:
a small file
a large file
a file that is "almost" sorted
another file that is almost sorted
a very dangerous file