CS 302 Assignment 4: Counting the Number of Comparisons of a Sorting Algorithm

Due date: Thursday, October 11, 2012, midnight.

All programming assignments must be submitted electronically. Submit them to the graduate assistant 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
  1. Reads real numbers from a file into an array of size no more than 1000, and reports the size of that array.
  2. Sorts the same array using heapsort.
  3. Counts the number of comparisons for each file and reports that number.
  4. You must use an array implementation of heapsort, such as the one I gave in class.


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