CPSC 170 Post Lab 6
Visual Sorting
Due Before Class on Friday, February 20th

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 the sorting algorithms you implemented in lab.

Details

Create a program that displays an array of Integers as circles in a window. Each circle is the same small size but is located and the x coordinate of its index in the array and at the y coordinate of its value. The window width is determined by the length of the array and the height by the range of values in the array. It is okay to assume that there are no integers with negative values in the array.

Add to the window a slider with a range equivalent to the number of elements in the Integer array. The position of the slider represents how many elements of the array have been sorted. So, when the user drags the slider from left to right the array becomes sorted, and when dragging from right to left the array becomes unsorted. To do this you will need to modify, or create new, sorting methods that take an aditional parameter that is the number of elements to sort before stopping. Every time the slider is moved, re-sort the same original random array and display the result.

Add a combo box to the window that can be used to select different sorting algorithms. Lastly, add the bubble sort algorithm (explained on page 549 of your book (you can use the source code in your book)) to your program.


Hand In: Tar and email your code to your instructor with a subject of cpsc170 postlab6.