Lab #2

 

CSC 2200 

Fall 2002



Up

Lab preparation (at home)

Goal
Write (implement) a C++ program to compare three simple sorting algorithms. The program should generate an integer array of a specified size filled with values in a given order. Once the input array is generated, your program will call a sorting function to sort the array to the increasing order. Your driver program will allow you to select size of the array, type of the initial ordering, and the sorting algorithm used to sort the array.

Description
Your program should utilize two classes. Class NumGen implements the functions for generating the input array, and class Sort implements the sorting algorithms. We supply the header files NumGen.h and Sort.h. You have to implement them. There you can also find the specification of each function. Your driver program has to take three command-line parameters. The first parameter is an integer that specifies the size of the array to sort. The second parameter is one of three letters I, D, R. This parameter determines if the array is initialized with values in the Increasing, Decreasing, or Random order. The third parameter is one of the letters I, B, or Q and describes whether the Insertion sort, Bubble sort or Quick sort algorithm is used to sort the array. For example, if you want to sort an array of size 1000 initially in decreasing order using the Bubble sort algorithm, you will run your program as follows: sort 1000 D B

Lab report

Expect we will measure performance of the sorting algorithms.
 


For problems or questions regarding this web contact besta@cs.wayne.edu.
Last updated: September 09, 2002.