|
Running the viewer
NOTE: I found some software that makes development a lot faster and improves windows in general:
Once you have the controls placed on the form and copied the code to
the code window, Press F5 to run the viewer. Immediately you will see this
window and be able to watch the sorting by clicking on one of the ten
methods.
At any time while the viewer is sorting you may change the method of
sorting simply by clicking that method. The horizontal slide bar will
control the speed. Additionally there are five small buttons on the left
that control sorting operations as follows:
- [R]eset (randomize) the array
- [S]top the sort (continue with any method)
- [N]ormal toggles with [P]artition
normal sorts the array without partitioning
partition divides the array at the midpoint
and sorts recursively.
- [>]ascending toggles with [<] descending
- [1]Single steps through the sort.
Click this, then [+] will appear. Subsequent
clicks to this [+] (or pressing a key) will
single step through the respective sort.
Click stop or reset to quit this mode.
These buttons allow some experimentation. You can, for instance, sort
the bars then change from ascending to descending without randomizing. The
subsequent sort will show you how the method behaves with an array that is
totally unordered. Also resorting an array that is already sorted (in the
same direction) might offer insight as to the viability of a sort method.
(In an application a sort method may be called to reorder an array after
only one element is added.)
Partitioning is programmed for all methods mostly to allow you to see why
recursion is not desirable. It may also offer insight for experimentation.
Since Quicksort and Merge sort are intrinsically recursive, this setting
will have no effect on them. Note, quicksort sorts macro to micro, while
mergesort sorts micro to macro.
The more advanced sort methods involve combinations of methods - like a
quick sort to a certain point and then an insertion sort. Modifying the
code should allow you to experiment with various combinations. Also some
more advanced methods like a radix sort involve the use of multiple arrays
(an input and one or more output arrays). These methods are beyond the
scope of this single array viewer.
Note that in the bottom right corner the key to the current operation
is displayed by the following color codes:
BLUE - No Operation
GREEN - Comparing
RED - Swapping
ORANGE - Minimum Midpoint or Maximum
<<Previous | Next >>
|