ACM Home Page
Please provide us with feedback. Feedback
On the adaptiveness of Quicksort
Full text PdfPdf (835 KB)
Source Journal of Experimental Algorithmics (JEA) archive
Volume 12 ,  (June 2008) table of contents
SECTION: SECTION: 3 - Special Issue table of contents
Article No. 3.2  
Year of Publication: 2008
ISSN:1084-6654
Authors
Gerth Stølting Brodal  MADALGO, University of Aarhus, Århus N, Denmark
Rolf Fagerberg  University of Southern Denmark, Odense M, Denmark
Gabriel Moruz  J. W. Goethe University, Frankfurt/Main, Germany
Publisher
ACM  New York, NY, USA
Bibliometrics
Downloads (6 Weeks): 15,   Downloads (12 Months): 131,   Citation Count: 0
Additional Information:

abstract   references   index terms   collaborative colleagues  

Tools and Actions: Request Permissions Request Permissions    Review this Article  
DOI Bookmark: Use this link to bookmark this Article: http://doi.acm.org/10.1145/1227161.1402294
What is a DOI?

ABSTRACT

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 that 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 for sorted inputs. 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 Quicksort. We also give some empirical results on the adaptive behavior of Heapsort and Mergesort.


REFERENCES

Note: OCR errors may be found in this Reference List extracted from the full text article. ACM has opted to expose the complete List rather than only correct and linked references.

 
1
 
2
Brodal, G. S. and Moruz, G. 2005. Tradeoffs between branch mispredictions and comparisons for sorting algorithms. In Proc. 9th International Workshop on Algorithms and Data Structures. Lecture Notes in Computer Science, vol. 3608. Springer Verlag, Berlin. 385--395.
 
3
Brodal, G. S., Fagerberg, R., and Moruz, G. 2005. Cache-aware and cache-oblivious adaptive sorting. In Proc. 32nd International Colloquium on Automata, Languages, and Programming. Lecture Notes in Computer Science, vol. 3580. Springer Verlag, Berlin. 576--588.
 
4
 
5
Elmasry, A. 2004. Adaptive sorting with avl trees. In 3rd IFIP International Conference on Theoretical Computer Science. 307--316.
 
6
 
7
Elmasry, A. and Hammad, A. 2005. An empirical study for inversions-sensitive sorting algorithms. In 4th International Workshop on Experimental and Efficient Algorithms. 597--601.
8
9
 
10
11
12
 
13
Hoare, C. A. R. 1962. Quicksort. The Computer Journal 5, 1 (April), 10--15.
 
14
 
15
 
16
Mehlhorn, K. 1984. Sorting and Searching. Springer Verlag, Berlin.
 
17
 
18
Pagh, A., Pagh, R., and Thorup, M. 2004. On adaptive integer sorting. In 12th Annual European Symposium on Algorithms, ESA 2004. Lecture Notes in Computer Science, vol. 3221. Springer Verlag, Berlin. 556--567.
 
19
papi 2004. PAPI (Performance Application Programming Interface). Software library found at http://icl.cs.utk.edu/papi/.
 
20
 
21
Sanders, P. and Winkel, S. 2004. Super scalar sample sort. In 12th Annual European Symposium on Algorithms, ESA 2004. Lecture Notes in Computer Science, vol. 3221. Springer Verlag, Berlin. 784--796.
 
22
Sedgewick, R. 1975. Quicksort. Ph.D. thesis, Stanford University, Stanford, CA. Stanford Computer Science Report STAN-CS-75-492.
 
23
Sedgewick, R. 1977. The analysis of quicksort programs. Acta Informatica 7, 327--355.
24
 
25
 
26
Seidel, R. 1992. Backwards analysis of randomized geometric algorithms. Tech. Rep. TR-92-014, International Computer Science Institute, Univeristy of Calfornia at Berkeley. February.
27
 
28
Williams, J. W. J. 1964. Algorithm 232: Heapsort. Communications of the ACM 7, 6, 347--348.

Collaborative Colleagues:
Gerth Stølting Brodal: colleagues
Rolf Fagerberg: colleagues
Gabriel Moruz: colleagues