Lab 1: Evaluating Sorting Algorithms

The goal of this lab is to practice writing sorting algorithms on arrays and to experiment with one metric for comparing the efficiency of different algorithms.

There are many ways to compare algorithms and their implementations, to consider how efficiently they make use of resources. The main resources of interest are time and space (that is, computer memory), but occasionally other resources (such as network bandwidth) are of concern.

Furthermore, there are several ways to study an algorithm's efficiency with respect to a specific resource-- it can be studied experimentally, theoretically, and probabilistically; looking at best case, worst case, average case, and expected case; and with various degrees of precision.

Most sorting algorithms rearrange the data in an array or list based on comparing pairs of data. (There do exist, however, sorting algorithms that do are not comparison-based.) Accordingly, one crude way to study the efficiency of sorting algorithms is to count the number of comparisons of data.

In this lab you will experiment with several sorting algorithms and compare their efficiency based on the number of comparisons they need to make to sort arrays.

As in most labs and projects, I am giving you some code base to work on. You may remember a driver program used to test sorting algorithms from certain labs and projects in Programming I. We will be using a version of that driver in this lab. You will complete certain sorting algorithms, and you will also add code to several algorithms which will count the number of times pairs of data are compared during the execution of the algorithm.


Thomas VanDrunen
Last modified: Tue Jan 12 14:02:55 CST 2010