Results 1 -
2 of
2
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 5 (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 Heap-Based Optimal Inversions-Sensitive Sorting Algorithm
, 2003
"... this paper, we describe a new time-optimal algorithm that makes n lg(I=n) + O(n lg lg(I=n) + n) comparisons. This is an optimal algorithm for inversions-sensitive sorting in the sense that it is time-optimal and the number of comparisons it performs matches the information-theoretic lower bound up t ..."
Abstract
- Add to MetaCart
this paper, we describe a new time-optimal algorithm that makes n lg(I=n) + O(n lg lg(I=n) + n) comparisons. This is an optimal algorithm for inversions-sensitive sorting in the sense that it is time-optimal and the number of comparisons it performs matches the information-theoretic 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 inversions-sensitive time-optimal 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 time-optimal and inversions-sensitive are Blocksort [LP96] which runs in place and tree-based Mergesort [MEP96] which is time-optimal with respect to several other measures of pre-sortedness

