Sort Tester V9 Fall 2017


Description

This app, inspired by Robert Sedgewick's Algorithms text (See [3]), provides visual demonstrations seven sorting algorithms:

Assume that we have a data set of size $n$ that can be ordered a key associated with each element of the data set. The keys could be integers, strings or something more complex. Then the cost of a sorting algoritm into increasing order is measured by

Note: Operations related to indexing of loops and other indexing operations involving integers or pointers are not measured as these kinds of computations are highly implementation dependent.

In table below the average and worst case costs in terms of comparisons is listed along with the amount of additional space used.

Sort Algorithm Worst Case Average Case Extra Space
Bubble $\Theta(n^{2})$ $\Theta(n^{2})$ In Place
Selection $\Theta(n^{2})$ $\Theta(n^{2})$ In Place
Insertion $\Theta(n^{2})$ $\Theta(n^{2})$ In Place
Quick $\Theta(n^{2})$ $\Theta(n \log n)$ $\propto n$
Shell
Depends on the gaps $\{h_{k}\}$ used:
I used $h_{k}=\frac{3^k-1}{2} <= \lceil \frac{n}{3}\rceil$
$\Theta(n^{\frac{3}{2}})$ In Place
Merge $\Theta(n \log n)$ $\Theta(n \log n)$ $n$
Heap $\Theta(n \log n)$ $\Theta( n \log n) $ In Place
Remarks

References

[1] Sara Bass, Computer Algorithms: Introduction to Design and Analysis, Addison-Wesley, 1983.
[2] R.L. Kruse, B.P. Leung, C.L. Tondo, Data Structures and Program Design in C, Prentice-Hall , 1991.
[3] Robert Sedgewick, Algorithms, Second Edition, Addison-Wesley, 1988.

Instructions

Use the

Finally, press the Sort button to begin the animation of the selected sort algorithm.