Augustana Faculty logo and wordmark


COMPUTING SCIENCE 210
Algorithm Analysis and Data Structures


Lab on Sorting Algorithms



Objectives

Lab

Download the following file to a location in your home directory tree on a computer in the senior lab:

. SortingLab.zip

Create a new Java project in Eclipse — call it something like SortingLab.

With the new project name highlighted, select the "Import" option from the File menu or by right-clicking the project name. Choose the "Archive file" option, and navigate to where you saved SortingLab.zip. Importing this archive file should create all the files you need in the SortingLab project.

Look at the file SortTester.java. You should see that there are three options provided for initializing an array of integers, two of which are commented out. You can choose whether you want the array of random integers to start out in random order, in increasing order, or in decreasing order by uncommenting and commenting out the appropriate lines of code.

Similarly, you can select between three sorting algorithms. The Java source code for these algorithms is not provided. Instead, you have only the Java class files, available as part of the jar file sortingAlgorithms.jar. The algorithms are selection sort, insertion sort, and heapsort, but you do not know which class file incorporates which algorithm.

Your challenge is to indentify the three sorting algorithms according to their run-time performance. Another program — SortTimer — is provided for your use in testing the three algorithms on various input sizes. Start by using randomly ordered arrays of size 1000, 2000, 3000, . . . You can also try sorting arrays that are already ordered and reverse-ordered to see if it gives you more hints about which algorithm is which.