CPSC170A Assignment 4
Visual Sorting

Due Friday, March 1st by 5:00 PM

Sometimes it is difficult to figure out how a sorting algorithm works by reading a description. It can be useful to visualize a sorting algorithm to better understand how it works and how it performs in certain situations. You are going to create a program that visualizes sorting algorithms you have implemented.

Details

Create a program that displays a list of integers as circles in a window. You will specify the width and the height of the window, and scale the list so that it fills the window. Each circle is the same small size but is located at an x coordinate of its index in the list and at a y coordinate proportional to its value. So for example, if the list is of length 500 and the values range between 0 and 400, then you should scale the x coordinate such that the item at list index 0 appears at the left side of the window, and scale the y coordinate so that it appears in the proper place in the window. This is very similar to how you scaled the plots from Lab 5.

Your program will generate a shuffled list of integers, and store that to be drawn. Your program should then allow the user to select a sorting algorithm to execute. The simplest way to accomplish this is by assigning each algorithm to a keyboard key. For example, assign the "q" key to selection sort, the "w" key to insertion sort, and the "e" key to bubble sort. For each iteration of the sorting algorithm, the window displaying the list should be re-drawn. This allows the user to visually watch the sorting taking place. An iteration for selection sort is one selection, for insertion sort is one insertion, and for bubble sort is one swap.

The user should be able to pick a new algorithm at any point during the execution. This should start the newly selected algorithm on the same, previously shuffled list. This way the user can view how different algorithms behave same list.

Submission: Submit your code as a zip file with your name as the zip file name on the course Inquire site.

Class Structure

Write down your class hierarchy. It should include the classes you intend to create, the attributes of those classes, and the methods those classes will implement.

For each attribute, write what data types you are storing in them, and why you are doing so. For each method, write the Pre and Post conditions for the method.

Submission: Submit on paper, at the beginning of lab on Tuesday, Feb. 26th 2013.

Extra

Comb sort: Add comb sort to the available sorts.