## CPSC 170 Post Lab 5

Visual Sorting

Due Before Class on Tuesday, February 22^{nd}

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. Each circle is the same small size but is located at the x coordinate of its index in the array and at the y coordinate of its value. For example, if the Integer at index 42 has a value of 21 then the circle would be drawn at the point (42, 21). The window width is determined by the length of the array and the window height by the range of values in the array. So for example, if the array is of length 500 and the values range between 0 and 400, then the window should be 500 by 400 pixels.

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 iterations of the sort method have been executed. An iteration for selection sort is one selection, for insertion sort is one insertion, and for bubble sort is one bubbling up. So for example, if the array size is 500 and the slider is at 50%, then 250 iterations of the sort method should be performed. 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. Every time the slider is moved, re-sort the same original random array and display the result. This will require storing the original array separately from the sorted array that is drawn to the window and modifying the sort methods to take a parameter that specifies how many iterations of the sort should be completed. Lastly, add a combo box to the window that can be used to select different sorting algorithms, selection, insertion, or bubble.

**Submission**: Tar and submit your code on the course Inquire site.