Results 1 
3 of
3
On the adaptiveness of quicksort
 IN: WORKSHOP ON ALGORITHM ENGINEERING & EXPERIMENTS, SIAM
, 2005
"... Quicksort was first introduced in 1961 by Hoare. Many variants have been developed, the best of which are among the fastest generic sorting algorithms available, as testified by the choice of Quicksort as the default sorting algorithm in most programming libraries. Some sorting algorithms are adapti ..."
Abstract

Cited by 8 (1 self)
 Add to MetaCart
Quicksort was first introduced in 1961 by Hoare. Many variants have been developed, the best of which are among the fastest generic sorting algorithms available, as testified by the choice of Quicksort as the default sorting algorithm in most programming libraries. Some sorting algorithms are adaptive, i.e. they have a complexity analysis which is better for inputs which are nearly sorted, according to some specified measure of presortedness. Quicksort is not among these, as it uses Ω(n log n) comparisons even when the input is already sorted. However, in this paper we demonstrate empirically that the actual running time of Quicksort is adaptive with respect to the presortedness measure Inv. Differences close to a factor of two are observed between instances with low and high Inv value. We then show that for the randomized version of Quicksort, the number of element swaps performed is provably adaptive with respect to the measure Inv. More precisely, we prove that randomized Quicksort performs expected O(n(1+log(1+ Inv/n))) element swaps, where Inv denotes the number of inversions in the input sequence. This result provides a theoretical explanation for the observed behavior, and gives new insights on the behavior of the Quicksort algorithm. We also give some empirical results on the adaptive behavior of Heapsort and Mergesort.
A HeapBased Optimal InversionsSensitive Sorting Algorithm
, 2003
"... this paper, we describe a new timeoptimal algorithm that makes n lg(I=n) + O(n lg lg(I=n) + n) comparisons. This is an optimal algorithm for inversionssensitive sorting in the sense that it is timeoptimal and the number of comparisons it performs matches the informationtheoretic lower bound up t ..."
Abstract
 Add to MetaCart
this paper, we describe a new timeoptimal algorithm that makes n lg(I=n) + O(n lg lg(I=n) + n) comparisons. This is an optimal algorithm for inversionssensitive sorting in the sense that it is timeoptimal and the number of comparisons it performs matches the informationtheoretic lower bound up to lower order terms. (To be precise, the number of comparisons performed by our algorithm is optimal with respect to its leading term and near optimal with respect to the second term. This is explained in the following section.) 2 Earlier Results Adaptive sorting using the nger trees data structure introduced in [GMPR77], was the rst inversionssensitive timeoptimal sorting algorithm. Mehlhorn [Me79] introduced an algorithm with the same time bounds as nger trees. Both of these algorithms are considered impractical. As summarized by Elmasry [El02], other algorithms that are timeoptimal and inversionssensitive are Blocksort [LP96] which runs in place and treebased Mergesort [MEP96] which is timeoptimal with respect to several other measures of presortedness
and
"... We study the performance of the most practical inversionsensitive internal sorting algorithms. Experimental results illustrate that adaptive AVL sort consumes the fewest number of comparisons unless the number of inversions is less than 1%; in such case Splaysort consumes the fewest number of compa ..."
Abstract
 Add to MetaCart
We study the performance of the most practical inversionsensitive internal sorting algorithms. Experimental results illustrate that adaptive AVL sort consumes the fewest number of comparisons unless the number of inversions is less than 1%; in such case Splaysort consumes the fewest number of comparisons. On the other hand, the running time of Quicksort is superior unless the number of inversions is less than 1.5%; in such case Splaysort has the shortest running time. Another interesting result is that although the number of cache misses for the cacheoptimal Greedysort algorithm was the least, compared to other adaptive sorting algorithms under investigation, it was outperformed by Quicksort.