Column 11 describes Insertion Sort and two Quicksorts (a simple version and the typical version using 2-way partitioning). Column 14 describes Heapsort. This page animates those algorithms and two additional simple sorting algorithms from the Solutions to Column 11: Selection Sort and Shell Sort.
To view an animation, hit the run button below. Each dot represents an element in the array; the x-value is the element's index and the y-value is the element's value. Thus a random array is a uniform smear of points, and a sorted array is a trail of points wandering from the bottom left to the top right.
To experiment with the algorithms, select a value of n, an input distribution, and a sorting algorithm before hitting run. For each algorithm, be sure to start with a small value of n, and work up to larger values. WARNING! There is no way to stop an animation in progress (this is a simple Java program) other than by terminating your browser. Enjoy!
This animation shows the essential algorithms, but has few bells and whistles. Most of the algorithms sort the array a[0..n-1]. BEWARE! The Heapsort takes a sleazy shortcut around the problem of zero-indexed arrays: it sorts the array a[1..n-1], and leaves a[0] dangling in mid-air.
The code for this animation is SortAnim.java, available with the rest of the source code.Copyright © 1999 Lucent Technologies. All rights reserved. Fri 14 July 2000