Department of Computer Science

Problem Solving and Algorithm Design I

Spring Semester 2010

Dr. Maury Eggen

Homework Laboratory Exercise 8

For this homework we shall study sorting. We shall implement four algorithms for sorting, the MaxSort, MinSort, BubbleSort, and the InsertionSort. Details of the algorithms were discussed in class.

Five separate programs and a discussion are required for the completion of this exercise.

Your programs must read the data to be sorted from a file and fill an array. You will print the unsorted array, sort the array, print the sorted array, and tell the number of comparisons required for the algorithm to work.

The rules are:

Finally, you should provide a description of which algorithm you think is best. You will analyze its average behavior, its best case behavior, and its worst case behavior. You will do this by having each of the algorithms sort arrays which are already in order, arrays which are exactly in reverse order, and three random arrays. The first random array has all elements on [0,9], the second has all elements on [0,99], and the third has its values on [0,999]. Discuss what effect (if any) having lots of repetitions has on the performance of the sort. You may use n=100. Summarize your findings in a table.

Homework requirements are the same as before, title page, description, source code, sample execution, and meaningful story.

Homework due date: Monday, March 29, 2010.

Return to Dr. Eggen's Home Page