Visual Basic Explorer
Visual Basic Explorer
 Navigation
 Home


 Coding
 Source Code

 FAQ Center

 VB Tips

 Downloads

 ToolBox

 Tutorials

 VB Games

 VB News

 VB Award

 VB Forums



 Affiliates
 Planet Source Code

 Rent a Coder

 DirectX4VB


 Misc
 Search

 Feedback

 Advertise

 About


Need to hire
a VB coder?

Please support our sponsor:

 Home 
 Site Map 
 Forums 
 News 
 Feedback 

Sorting Viewer

A Visual Basic® Tutorial


Running the Viewer


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.

Overview
Copy the Code
Winning the Little Battles
Sorting Methods Discussed
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




Home | About | What's New | Source Code | FAQ | Tips & Tricks | Downloads | ToolBox | Tutorials | Game Programming | VB Award | Search | VB Forums | Feedback | VBNews | Copyright & Disclaimer | Advertise | Privacy Policy |

Quick searches: Site Search | Advanced Site Search 

Copyright 2002 by Exhedra Solutions, Inc.
By using this site you agree to its terms and conditions
VB Explorer and VBExplorer.com are trademarks of Exhedra Solutions, Inc.