Sorting Algorithm Comparison Chart
Sorting Algorithm Comparison Chart
Notation:
O(x) = Worst Case Running Time
Ω(x) = Best Case Running Time
Θ(x)= Best and Worst case are the same.
First Pass:
Data: 67 50 70 25 93 47 21
That data is created by doing a single pass on the unsorted data, using the offsets to
work out at where each item belongs.
For example, it looks at the first one 67, then at the offsets for the digit 7, and inserts it
into the 5th position. The offset at 7 is then incremented, so that the next value
encountered which has a least significant digit of 7 is placed into the 6th position.
Continuing the example, the number 50 would then be looked at, and inserted into the
0th position, its offset incremented, so that the next value which is 70 would be
inserted into the 1st position, and so on until then end of the list.
As you can see, this data is sorted by its least significant digit.
Second Pass:
Data after first pass
50 70 21 93 25 67 47
Look at this diagram for another example, noting that the "offsets" array is
unnecessary
Images:
Straight Insertion - Figure 15.2
Bubble Sorting - Figure 15.3
Quick Sorting - Figure 15.4
Program 15.7 AbstractQuickSorter code
Program 15.9 MedianOfThreeQuickSorter class selectPivot method
Straight Selection Sorting - Figure 15.5
Building a heap - Figure 15.7
Heap Sorting - Figure 15.8
Two-way merge sorting - Figure 15.10