
CS 302 Assignment 2:
Counting the Number of Comparisons of a Sorting Algorithm
Due date: Tuesday, September 16, 2008, midnight.
All programming assignments must be
submitted electronically.
Submit them to the graduate assistant,
Chitwan Gupta, by email at
guptac"at"unlv"dot"nevada"dot"edu
on or before the due date.
Your email must come from your engineering college (or computer science
or computer engineering) account.
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 selection sort.
-
Sorts the array using insertion sort.
-
Sorts the array using bubblesort.
-
Sorts the same array using mergesort.
-
Sorts the same array using quicksort.
-
Counts the number of comparisons for each of the five sorting
algorithms, and reports that number.
Use the following two files to test your program:
a small file
a large file