Sortier-Algorithmen

Mit den Applets dieser Seite können Sie die Arbeitsweise von Sortieralgorithmen, wie sie unter anderem in der Lehrveranstaltung IAD vorkommen, nachvollziehen. Die Java-Quellen (ursprünglich von James Gosling und Jason Harrison, modifiziert von A. Weinert, stehen zur Anschauung und zum (Java-) Üben bereit: Von allen Quellen ist SortApplet.java (im Vergleich zu den beiden Originalen) sehr stark modifiziert. Bei Darstellung, Doppelpufferung, Ereignismodell etc.. hat SortApplet.java mit den beiden Ausgangsquellen nur noch wenig zu tun. Verglichen damit sind die übrigen Modifikationen aller anderen Quellen bestenfalls kosmetisch, u.A. in so fern, dass die Anzahl der Compiler- und JavaDoc-Warnungen von 160 auf 0 gebracht wurde.

Das Folgende ist (weitgehend) die Originalbeschreibung von James Gosling.

We all know that Quicksort is one of the fastest algorithms for sorting. It's not often, however, that we get a chance to see exactly how fast Quicksort really is. The following Applets chart the progress of several common sorting algorithms while sorting an array of data using in-place algorithms. This means that the algorithms do not allocate additional storage to hold temporary results: they sort the data in place. (This is inspired by the algorithm animation work at Brown University and the video Sorting out Sorting By Ronald Baecker from the University of Toronto (circa 1970!).)

Some of these sorts are very stupid or very slow and should not be used in code. The use of Bubblesort is deprecated.

In-Place Mergesort is yet another abomination. Mergesort is supposed to run in O(n log n), but the implementation here runs in O(n * n). This is because a temporary scratch array is not used. As with most of the examples here, In-Place Mergesort sorts the elements in the array without using additional storage (other than the stack used for the recursive calls, and temporary variables). Jack Snoeyink has provided me with a the Double Storage mergesort algorithm sort implementation that uses a scratch array.

Click on each applet to see the algorithm run. Click on the name of the algorithm to see the source.
Klicken Sie auf das jeweilige Applet, um den Algorithmus arbeiten zu sehen. Klicken Sie auf den Namen um die Quelle (.java) zu sehen.

Bubble Sort (J. Gosling & J. Harrison)


Bi-Directional Bubble Sort (J. Gosling)



Selection Sort (by Jason Harrison)


Shaker Sort (by Jason Harrison)



Insertion Sort (by Jason Harrison)


In-Place Merge Sort (by Jason Harrison)



Double Storage Merge Sort (J. Snoeyink)


Comb Sort 11 (by Jason Harrison)



Shell Sort (by Jason Harrison)


Heap Sort (by Jason Harrison)



Quick Sort (by James Gosling)


Quick Sort with Bubblesort (by Jim Boritz)



Enhanced Quick Sort (by Jim Boritz)


Fast Quick Sort (by Denis Ahrens)



Radix Sort Algorithm (by Alvin Raj)



What's missing ... If you'd like to code any of those algorithms, please do and send me the code.

Metrics to be added: One of my favourite references to sorting routines is "Sorting" by William A. Martin, in ACM Computing Surveys, Volume 3, Number 4, December 1971, pages 147-174. The abstract reads:
The bibliography appearing at the end of this article lists 37 sorting algorithms and 100 books and papers on sorting published in the last 20 years. The ideas presented here have been abstracted from this body of work, and the best algorithms known are given as examples. As the algorithms are explained, references to related algorithms and mathematical or experimental analyses are given. Suggestions are then made for choosing the algorithm best suited to a given situation.

Disclaimer: If you use this page as part of your teaching, please let me know. I tend to refer students who ask too many questions back to their instructor. Requests for translations of the Java sources to other programming languages will be denied. This page was created in a fit of "thesis avoidance" in the summer of 1996.
James Gosling


Originally created by
Stand: 12, 8.09.2011.