Assignment 3
Sorting Sleuths!
DUE at the beginning of class, Wednesday, August 7th

I. Introduction

Because of your recent success discerning between Shakespeare and Bacon texts, you have been commissioned once again for your detective prowess. If all goes well with this assignment, there is a good chance you will be offered your dream role in the new television detective drama, Cold Hard Cache. The lead character is a robotic chimpanzee named Banana Cache, and you will be playing Banana's sidekick as the two of you solve one zany computer mystery after another. Before the director gives you an audition, however, she wants to ensure that you have sufficient data structures and algorithms skills (so that there's plenty of "chemistry" between you and Banana), so she tests you with the following bit of sorting sleuthing...

II. Learning Objectives

For this assignment, you will:

III. Sorting Analysis

In this assignment, you will be investigating a Java program which runs 7 different sorting algorithms: BubbleSort, HeapSort, InsertionSort, MergeSort, QuickSort, RandomizedQuickSort, and SelectionSort. The program has 7 different buttons, one for each of the sorting algorithms, but the problem is that nobody knows which button runs which sorting algorithm. It is your job to determine which button runs which sorting algorithm (and impress Banana Cache in the process)!

First, the program allows you to create a list of numbers which need to be sorted. You can select how many numbers you want in your list to be sorted. Also, you can select whether you want the list of numbers to be in random order to start with, or else in sorted order, or in reverse sorted order, or in nearly sorted order.

When you sort the list of numbers, the program indicates how many comparisons the sorting algorithm required, how many movements the sorting algorithm required, and how much time the algorithm took. The number of movements is the number of times an element in the list is a part of an assignment statement. For instance, list[0] = temp; and temp = list[0]; and list[0] = list[1]; each count as one movement. You can assume that when 2 elements in the list are swapped, it counts as 3 movements.

IV. Program Availability

You can download the files here or you can get them from the course directory /projects/cse/courses/cse326/02su/assignment3/. This is a tar archive, so named because of the program used to create it (Tape ARchive). This is a common way to distribute groups of files in Unix. Unpack the archive with
    tar xvf sortingSleuth.tar
If you like, see man tar for details on what you just did. Now to run the program, make sure the current directory contains the file SortDetective.class and type
    java SortDetective

V. What to Turn In

VI. Credits

The original inspiration for this assignment comes from David Levine, of the Computer Science department at St. Bonaventure University. The idea for this assignment comes from the "Nifty Assignments " session at the annual ACM SIGCSE meeting.