
CS 302 Assignment 2:
Counting the Number of Comparisons of a Sorting Algorithm
Due date: Thursday, Februay 7, 2013, midnight.
All programming assignments must be
submitted electronically.
Submit them to the graduate assistant,
Jimi Andro-Vasko, by email at
androvas "at" unlv "dot" nevada "dot" edu
on or before the due date.
Your email must come from your university or engineering college 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 bubblesort.
-
Sorts the array using quicksort.
-
Counts the number of comparisons for each of the 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.
Do you expect bubblesort to do better in this case?
another file that is almost sorted.