Animated Sorting Algorithm Demo

Size:  20 · 30 · 40 · 50

Insertion

Selection

Bubble

Shell

Merge

Heap

Quick

Quick3

Random

Nearly

Reversed

Few Unique

Discussion

These pages show 8 different sorting algorithms on 4 different initial conditions. These visualizations are intended to:

The ideal sorting algorithm would have the following properties:

There is no algorithm that has all of these properties, and so the choice of the optimal sorting algorithm depends on the application.

Directions

Key

References

Algorithms in Java, Parts 1-4, 3rd edition by Robert Sedgewick. Addison Wesley, 2003.

Programming Pearls by Jon Bentley. Addison Wesley, 1986.