Introsort Screen
Introsort Screen
Introsort
Sequence
Algorithm 2.1
Comparison
Permuting 2.5
Based 2.2
Sorting Algorithm 2.6
Introsort
Observations:
1
See also Sorting Algorithm Operation Counts (2.91) for a similar table.
Table 2 shows the same comparison for median-of-3 killer sequences as
input data.
Using the iterator tracing tool we have generated plots that illustrate
the workings of introsort on different input sequences of size 1024. The
version of introsort that we used was the one implemented in SGI STL.
The first plot shows the iterator traces for a random input sequence. Up
to time 43000 we basically have the behavior of quicksort, which sorts
sequences larger than a certain minimum size. When only sequences
smaller than this size remain, the algorithm switches to insertionsort,
which is applied once to the entire sequence.
1200
vector_sort.log
1000
800
600
400
200
0
0 10000 20000 30000 40000 50000 60000 70000
The behavior for an already sorted sequence is similar except that the
median-of-three strategy always finds the perfect pivot and that inser-
tionsort at the end does not really have anything to do.
1200
vasc1024.log
1000
800
600
400
200
0
0 5000 10000 15000 20000 25000 30000 35000 40000 45000
For the median-of-three killer sequence the picture is quite different how-
ever. Quicksort fails bitterly and after reaching a maximum number of
recursions, the algorithm switches to heapsort to finish the work.
1200
vm31024.log
1000
800
600
400
200
0
0 50000 100000 150000 200000 250000 300000 350000