home *** CD-ROM | disk | FTP | other *** search
-
- SORTDEMO
- ver 1.0
-
- by Jon S. Russell
-
-
- -----------------------------------------------------------------------------
-
- HARDWARE REQUIREMENTS:
-
- SORTDEMO requires an IBM compatible computer with
- VGA graphics capabilities, and 640k memory.
-
- -----------------------------------------------------------------------------
-
- MANIFEST:
- These files should be included with the SORTDEMO package.
-
- SORTDEMO.EXE .. executable program
- SORTDEMO.DOC .. this file (documentation)
- SORTDEMO.PAS .. Turbo Pascal source file
- SDGRAF .INC .. Turbo Pascal include file (basic graphics routines)
- SDKEY .INC .. Turbo Pascal include file (keyboard routines)
- SDTIME .INC .. Turbo Pascal include file (time-keeping routines)
- SDFILE .INC .. Turbo Pascal include file (file-related routines)
- SDDISP .INC .. Turbo Pascal include file (info-display/menuing routines)
- SDMISC .INC .. Turbo Pascal include file (misc routines)
- SDSORT01.INC .. Turbo Pascal include file (Bubble Sort routine)
- SDSORT02.INC .. Turbo Pascal include file (Short-Bubble Sort routine)
- SDSORT03.INC .. Turbo Pascal include file (Selection Sort routine)
- SDSORT04.INC .. Turbo Pascal include file (Merge Sort routine)
- SDSORT05.INC .. Turbo Pascal include file (QuickSort #1 routine)
- SDSORT06.INC .. Turbo Pascal include file (QuickSort #2 routine)
- SDSORT07.INC .. Turbo Pascal include file (Heap Sort routine)
- REGISTER.FRM .. Registration form (ASCII text)
- VGA256 .BGI .. Borland's VGA mode 13h driver (rqrd for SORTDEMO to work)
-
- If any of these files are missing, contact the author, (Jon Russell) via
-
- THE DREAMWEAVER BBS 2400 8/N/1 @ 817-668-1375.
-
- This is a new BBS as of 1992 and at the time of this release is operating
- from 7:00pm to midnight weekdays and 24hrs on weekends.
-
- -----------------------------------------------------------------------------
-
- OPERATION:
-
- Running SORTDEMO is pretty simple, upon starting the program a title
- screen is displayed, simply press any key to go to the main menu.
- Using the menu requires that you select the desired settings by using
- the left and right arrow keys to move the highlighted area title and the
- up and down arrow keys to select the desired setting. Pressing enter at
- any time the menu is displayed will execute the function defined by the
- Operation slider using the parameters defined by the other areas.
-
- The layout of the menu is something like this...
-
-
- <X-size> <Y-size> <Method> <Stats file>
- ■ 20 ■ 1 ■ Bubble Sort yes
- 40 2 Short Bubble ■ no
- 80 4 Selection Sort
- 160 5 Merge Sort <Operation>
- 8 QuickSort #1 ■ mix
- 10 QuickSort #2 sort
- 20 Heap Sort quit
- 25
- 50
-
- Array size: xxxx Array status: sorted
-
-
- <X-size> selects the number of colored blocks across the screen.
- <Y-size> selects the number of colored blocks up and down the screen.
- <Method> selects the sorting routine to use.
- <Stats file> toggles piping of the analysis information to a text file
- named SDSTATS.DAT. (This file may be viewed with any text
- viewer or editor).
- <Operation> selects the next operation to execute.
-
-
- Next to each of the areas there is a slider bar showing the current
- selection of that area. Using the left/right arrow keys, move to the
- X-size and Y-size areas to select the size of the array to be sorted,
- notice that the Array size shown below is updated each time the sliders
- on X-size or Y-size are moved. (The array size is calculated by
- X-size * Y-size). With the Operation slider pointing to mix, press the
- enter key. The menu will disappear and a graphical representation of
- the array will be shown such that there are X-size blocks across the
- screen and Y-size blocks up and down the screen. The blocks are initially
- arranged so that their colors are ordered by columns. The mix routine
- starts swapping color blocks thus mixing the array. When you feel the
- array is sufficiently mixed, press any key and you will go back to the
- menu screen. Notice that the Array status now shows the array to be
- unsorted. Now use the up/down arrow keys to move the Operation slider
- to sort, then use the left/right arrow keys to move the current area to
- <Method> and use the up/down arrow keys to select a sorting method. Press
- enter when you have done this, and the colored blocks will reappear back
- on the screen as they were when you finished mixing them. The selected
- sort routine will immediately take over and sort the colored blocks back
- to their orginal order, (all columns of the same color). When the sorting
- routine is finished, an Analysis screen is displayed. The analysis screen
- simply displays some information about the sort just completed, ie the
- sort method used, the size of the array sorted, time started and stopped,
- and the length of time required to complete the sort. Note that if the
- <Stats file> slider were set to yes, this information would also be saved
- to a text file named SDSTATS.DAT. When you are done reading the analysis,
- press any key to return to the menu screen and change the array size or
- the sorting method, remix and resort, etc.
-
- -----------------------------------------------------------------------------
-
- ABOUT SORTDEMO:
-
- The sorting routines presented here (in the files SDSORT0?.INC) are
- not written for maximum speed, some performance was traded for ease
- of understanding/clairity. If you were to modify these routines for use
- in your own programs and wanted to make them as fast as possible,
- I would suggest (for starters) doing things like rewritting the sort
- routine so that there were no internal procedure/function calls. Make
- the routine as self contained as possible. For example instead of calling
- a procedure such as Swap(a,b); replace any calls with something like...
-
- Temp := a;
- a := b;
- b := temp;
-
- Do the same with as many other calls as possible. Another way to speed
- up sorting routines is to sort pointers to the appropriate records as
- opposed to sorting the records themselves. This can be a substantial
- improvement especially if your data records are large. It takes the
- computer much less time (and memory) to exchange pointer values than it
- would to exchange a data record like...
-
- EmployeeType = record
- FirstName : string;
- LastName : string;
- ID_Num : integer;
- HireDate : DateType;
- .
- .
- .
- end;
-
- Selection of the proper sorting technique is essential to any program
- that requires efficient performance. For example, the bubble sort is
- better when working with small arrays than the merge sort, but if working
- with larger arrays, the merge sort technique more than doubles the memory
- requirements. The short bubble sort is usually pretty efficient if only
- a small number of elements are out of order, while the heap sort is only
- efficient when working with arrays that are thoroughly mixed up. Use
- SORTDEMO to experiment with sorting various sized arrays and sorting
- arrays only slightly out of order or try to sort an array that is already
- sorted. You may find the results quite suprising.
-
- The sorting methods presented here are by no means all of the techniques
- available, I have just implemented a few of the more popular ones. I have
- attempted to write SORTDEMO in such a manner that it would be fairly easy
- for you to try out other techniques. Just write your own routine as
- an include file, and substitute if for the appropriate include file (ie
- SDSORT01), and recompile.
-
- -----------------------------------------------------------------------------
-
- REGISTRATION:
-
- Registration for SORTDEMO is $10.00. If you find SORTDEMO of use, please
- register it. I am currently working on a program that will graphically
- explain in depth how various sorting routines work. Registering SORTDEMO
- will get you a copy of this program. To register, print out the text file
- REGISTER.FRM, complete all applicable information, and mail it to:
-
- Jon Russell
- 1511 Mill
- Gainesville, TX 76240
-
- Your registration fee will help me to contend with the rising cost of
- education. I am currently studying Computer Science at the University
- of North Texas.
-
- -----------------------------------------------------------------------------
-
- CREDITS:
-
- Turbo Pascal is a product of Borland International.
-
- SORTDEMO was developed with Turbo Pascal 6.0 but the source code
- "should" compile with Turbo Pascal 5.0 and 5.5 also.
-
- The sort routines used here were modified from the book
- "Pascal Plus Data Structures" by Nell Dale & Susan C. Lilly.
-
- -----------------------------------------------------------------------------
-
- DISCLAIMER:
-
- This product is distributed AS IS. The author specifically disclaims
- all warrienties, expressed or implied, including but not limited to
- implied warranties of merchantability and fitness for a particular
- purpose. In no event shall the author be liable for any loss of profit
- or any other commercial damage including but not limited to special,
- incidental, consequential or other damages.
-
-