Abstract
Recently, a new Quicksort variant due to Yaroslavskiy was chosen as standard sorting method for Oracle’s Java 7 runtime library. The decision for the change was based on empirical studies showing that on average, the new algorithm is faster than the formerly used classic Quicksort. Surprisingly, the improvement was achieved by using a dual pivot approach, an idea that was considered not promising by several theoretical studies in the past. In this paper, we identify the reason for this unexpected success. Moreover, we present the first precise average case analysis of the new algorithm showing e.g. that a random permutation of length n is sorted using \(1.9n\ln n-2.46n+\mathcal{O}(\ln n)\) key comparisons and \(0.6n\ln n+0.08n+\mathcal{O}(\ln n)\) swaps.
This research was supported by DFG grant NE 1379/3-1.
This is a preview of subscription content, log in via an institution.
Buying options
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsPreview
Unable to display preview. Download preview PDF.
References
Hoare, C.A.R.: Quicksort. The Computer Journal 5(1), 10–16 (1962)¸
Sedgewick, R.: Quicksort. Phd thesis, Stanford University (1975)
Hennequin, P.: Analyse en moyenne d’algorithme, tri rapide et arbres de recherche. Ph.d. thesis, Ecole Politechnique, Palaiseau (1991)
Frazer, W.D., McKellar, A.C.: Samplesort: A Sampling Approach to Minimal Storage Tree Sorting. Journal of the ACM 17(3), 496–507 (1970)
Sanders, P., Winkel, S.: Super Scalar Sample Sort. In: Albers, S., Radzik, T. (eds.) ESA 2004. LNCS, vol. 3221, pp. 784–796. Springer, Heidelberg (2004)
Leischner, N., Osipov, V., Sanders, P.: GPU sample sort. In: 2010 IEEE International Symposium on Parallel Distributed Processing IPDPS, pp. 1–10. IEEE (2009)
Blelloch, G.E., Leiserson, C.E., Maggs, B.M., Plaxton, C.G., Smith, S.J., Zagha, M.: A comparison of sorting algorithms for the connection machine CM-2. In: Proceedings of the Third Annual ACM Symposium on Parallel Algorithms and Architectures - SPAA 1991, pp. 3–16. ACM Press, New York (1991)
Sedgewick, R.: Implementing Quicksort programs. Comm. ACM 21(10), 847–857 (1978)
Sedgewick, R.: Quicksort with Equal Keys. SIAM Journal on Computing 6(2), 240–267 (1977)
Sedgewick, R.: The analysis of Quicksort programs. Acta Inf. 7(4), 327–355 (1977)
Hoare, C.A.R.: Algorithm 63: Partition. Comm. 4(7), 321 (1961)
Bentley, J.L.J., McIlroy, M.D.: Engineering a sort function. Software: Practice and Experience 23(11), 1249–1265 (1993)
Hennequin, P.: Combinatorial analysis of Quicksort algorithm. Informatique Théorique et Applications 23(3), 317–333 (1989)
Laube, U., Nebel, M.E.: Maximum likelihood analysis of algorithms and data structures. Theoretical Computer Science 411(1), 188–212 (2010)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2012 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Wild, S., Nebel, M.E. (2012). Average Case Analysis of Java 7’s Dual Pivot Quicksort. In: Epstein, L., Ferragina, P. (eds) Algorithms – ESA 2012. ESA 2012. Lecture Notes in Computer Science, vol 7501. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-33090-2_71
Download citation
DOI: https://doi.org/10.1007/978-3-642-33090-2_71
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-642-33089-6
Online ISBN: 978-3-642-33090-2
eBook Packages: Computer ScienceComputer Science (R0)