Sorting Demo

Mergesort in progress
Mergesort in progress.

Sorting Demo is a powerful tool for demonstrating how sorting algorithms work. It was designed to alleviate some of the difficulty instructors often have in conveying these concepts to students due to lack of blackboard space and having to constantly erase. This program started out as a quicksort demonstration applet, and after proposing the idea to Seton Hall's math and computer science department, I was given permission to expand the idea to encompass many of the sorts commonly taught in a data structures/algorithms class. There are currently 9 algorithms featured, all of which allow you to either type in your own array or make the computer generate a random array of a milestone size. Although graphics limit the input array to a length of 25 elements, there is the option to run the algorithm without graphics in order to get an understanding of its running time in comparison with the other sorts.



Naturally, I consulted a number of sources for information on the implementation of these algorithms. They are as follows:

Cormen, Thomas H., Charles E. Leiserson, and Ronald L. Rivest. Introduction to Algorithms.
     Cambridge: The MIT Press, 1990.
Kitchen, Andrew. OETransSortAlgorithm.java.
     http://www.cs.rit.edu/~atk/Java/Sorting/OETransSortAlgorithm.java: 1995.
Kitchen, Andrew. ShearSortAlgorithm.java.
     http://www.cs.rit.edu/~atk/Java/Sorting/ShearSortAlgorithm.java: 1995.
Sedgewick, Robert. Algorithms. Reading, MA: Addison-Wesley Publishing Company, 1983.
Snoeyink, Jack. ExtraStorageMergeSortAlgorithm.java.
     http://www.cs.ubc.ca/spider/harrison/Java/ExtraStorageMergeSortAlgorithm.java: 1995.
Wirth, Niklaus. Algorithms + Data Structures = Programs. Englewood Cliffs: Prentice Hall, Inc., 1976.

Revision History

  • v2.04 - April 7, 2015
    • Fixed a bug that caused shearsort to work incorrectly on certain inputs. (Thanks, Harry Robinson!)
  • v2.03 - October 20, 2014
    • Changed relational operator in mergesort to make the algorithm a "stable" sort.
  • v2.02 - November 22, 2008
    • Changed background color of GUI.
    • Changed "OK" button to "Start" button.
    • Centered popup windows.
  • v2.01 - July 5, 2006
    • Fixed issue with threads where demos would skip steps under Linux.
    • Increased size of help window to prevent unnecessary wrapping.
  • v2.00 - March 1, 2002
    • Redesigned the GUI for the embedded applet and converted popup frames to GridBagLayout to ensure equal spacing of panels.
    • Removed usage of deprecated Thread methods.
    • Removed usage of sun.audio package.
    • Corrected code causing dialog boxes to appear minimized under Linux.
    • Added a parameter to set the background color of the applet.
    • Added "15" to the list of available lengths for special-case arrays.
    • Redesigned shearsort demo to fit in 800x600 resolution.
  • v1.15 - November 8, 2000
    • Added shearsort demo.
    • Corrected inconsistent code highlighting in heapsort demo.
  • v1.14 - October 12, 2000
    • Added shearsort demo.
    • Corrected inconsistent code highlighting in heapsort demo.
  • v1.03 - September 14, 2000
    • Fixed the double buffering error that sometimes caused the program to pause.
  • v1.02 - August 10, 2000
    • "2k+1" sequence now correctly reads "2^k-1" for k = x, x-1,..., 1 in shellsort help.
    • In shellsort demo, sorted strides are displayed in a different color than sorted subarrays.
  • v1.01 - August 7, 2000
    • Included computer-generated "sorted" and "reverse sorted" arrays.
    • Corrected O-E transposition sort algorithm.
  • v1.00 - July 10, 2000
    • Initial release.

Legal Limitations

  • It is illegal to modify and distribute the class files and/or to package the applet with other programs on CD-ROM, web sites, or any other media without my permission.
  • It is permissible to link to this site and to distribute the applet as it appears here for educational purposes only, as long as no profit is generated.

Source Code