, Volume 74, Issue 1, pp 485–506 | Cite as

Analysis of Quickselect Under Yaroslavskiy’s Dual-Pivoting Algorithm

  • Sebastian Wild
  • Markus E. Nebel
  • Hosam Mahmoud


There is excitement within the algorithms community about a new partitioning method introduced by Yaroslavskiy. This algorithm renders Quicksort slightly faster than the case when it runs under classic partitioning methods. We show that this improved performance in Quicksort is not sustained in Quickselect; a variant of Quicksort for finding order statistics. We investigate the number of comparisons made by Quickselect to find a key with a randomly selected rank under Yaroslavskiy’s algorithm. This grand averaging is a smoothing operator over all individual distributions for specific fixed order statistics. We give the exact grand average. The grand distribution of the number of comparison (when suitably scaled) is given as the fixed-point solution of a distributional equation of a contraction in the Zolotarev metric space. Our investigation shows that Quickselect under older partitioning methods slightly outperforms Quickselect under Yaroslavskiy’s algorithm, for an order statistic of a random rank. Similar results are obtained for extremal order statistics, where again we find the exact average, and the distribution for the number of comparisons (when suitably scaled). Both limiting distributions are of perpetuities (a sum of products of independent mixed continuous random variables).


Quicksort Quickselect Average-case analysis Grand average Contraction 

Mathematics Subject Classification

Primary: 60C05 Secondary: 68P10 68P20 


  1. 1.
    Hoare, C.A.R.: Quicksort. Comput. J. 5(1), 10–16 (1962)zbMATHMathSciNetCrossRefGoogle Scholar
  2. 2.
    Hoare, C.A.R.: Algorithm 65: find. Commun. ACM 4(7), 321–322 (1961)CrossRefGoogle Scholar
  3. 3.
    Sedgewick, R.: The analysis of quicksort programs. Acta Inform. 7(4), 327–355 (1977)zbMATHMathSciNetCrossRefGoogle Scholar
  4. 4.
    Wild, S., Nebel, M.E.: Average case analysis of Java 7’s dual pivot quicksort. In: Epstein, L., Ferragina, P. (eds.) ESA 2012, LNCS, vol. 7501, pp. 825–836. Springer, Berlin (2012)Google Scholar
  5. 5.
    Kirschenhofer, P., Prodinger, H.: Comparisons in Hoare’s Find algorithm. Comb. Probab. Comput. 7(01), 111–120 (1998)zbMATHMathSciNetCrossRefGoogle Scholar
  6. 6.
    Knuth, D.E.: The Art Of Computer Programming: Searching and Sorting, 2nd edn. Addison Wesley, Reading (1998)Google Scholar
  7. 7.
    Fill, J.A.: Distributional convergence for the number of symbol comparisons used by quicksort. Ann. Appl. Probab. 23(3), 1129–1147 (2013)zbMATHMathSciNetCrossRefGoogle Scholar
  8. 8.
    Mahmoud, H.M.: Distributional analysis of swaps in quick select. Theor. Comput. Sci. 411, 1763–1769 (2010)zbMATHCrossRefGoogle Scholar
  9. 9.
    Martínez, C., Prodinger, H.: Moves and displacements of particular elements in quicksort. Theor. Comput. Sci. 410(21–23), 2279–2284 (2009)zbMATHCrossRefGoogle Scholar
  10. 10.
    Wild, S., Nebel, M.E., Neininger, R.: Average case and distributional analysis of Java 7’s dual pivot quicksort. ACM Trans. Algorithms (accepted for publication).
  11. 11.
    Hennequin, P.: Analyse en moyenne d’algorithmes: tri rapide et arbres de recherche. PhD Thesis, Ecole Politechnique, Palaiseau (1991)Google Scholar
  12. 12.
    Sedgewick, R.: Quicksort. PhD Thesis, Stanford University (1975)Google Scholar
  13. 13.
    Hennequin, P.: Combinatorial analysis of quicksort algorithm. Informatique théorique et applications 23(3), 317–333 (1989)zbMATHMathSciNetGoogle Scholar
  14. 14.
    Bentley, J.: Programming pearls: how to sort. Commun. ACM 27(4), 287–291 (1984)CrossRefGoogle Scholar
  15. 15.
    Chung, K.L.: A Course in Probability Theory, 3rd edn. Academic Press, New York (2001)Google Scholar
  16. 16.
    Embrechts, P., Klüppelberg, C., Mikosch, T.: Modelling Extremal Events. Springer, Berlin (1997)zbMATHCrossRefGoogle Scholar
  17. 17.
    Alsmeyer, G., Iksanov, A., Rösler, U.: On distributional properties of perpetuities. J. Theor. Probab. 22, 666–682 (2009)zbMATHCrossRefGoogle Scholar
  18. 18.
    Wild, S.: Java 7’s Dual Pivot Quicksort. Master thesis, University of Kaiserslautern (2012)Google Scholar
  19. 19.
    Mahmoud, H.M., Modarres, R., Smythe, R.T.: Analysis of quickselect: an algorithm for order statistics. Informatique théorique et applications 29(4), 255–276 (1995)zbMATHMathSciNetGoogle Scholar
  20. 20.
    Lent, J., Mahmoud, H.M.: Average-case analysis of multiple quickselect: an algorithm for finding order statistics. Stat. Probab. Lett. 28(4), 299–310 (1996)zbMATHMathSciNetCrossRefGoogle Scholar
  21. 21.
    Prodinger, H.: Multiple quickselect—Hoare’s Find algorithm for several elements. Inf. Process. Lett. 56(3), 123–129 (1995)zbMATHMathSciNetCrossRefGoogle Scholar
  22. 22.
    Panholzer, A., Prodinger, H.: A generating functions approach for the analysis of grand averages for multiple QUICKSELECT. Random Struct. Algorithms 13(3–4), 189–209 (1998)zbMATHMathSciNetCrossRefGoogle Scholar
  23. 23.
    Rösler, U.: A limit theorem for “quicksort”. Informatique théorique et applications 25(1), 85–100 (1991)zbMATHGoogle Scholar
  24. 24.
    Rachev, S.T., Rüschendorf, L.: Probability metrics and recursive algorithms. Adv. Appl. Probab. 27(3), 770–799 (1995)zbMATHCrossRefGoogle Scholar
  25. 25.
    Neininger, R.: On a multivariate contraction method for random recursive structures with applications to quicksort. Random Struct. Algorithms 19(3–4), 498–524 (2001)zbMATHMathSciNetCrossRefGoogle Scholar
  26. 26.
    Neininger, R., Rüschendorf, L.: A general limit theorem for recursive algorithms and combinatorial structures. Ann. Appl. Probab. 14(1), 378–418 (2004)zbMATHMathSciNetCrossRefGoogle Scholar
  27. 27.
    Rösler, U.: On the analysis of stochastic divide and conquer algorithms. Algorithmica 29(1), 238–261 (2001)zbMATHMathSciNetCrossRefGoogle Scholar
  28. 28.
    Rösler, U., Rüschendorf, L.: The contraction method for recursive algorithms. Algorithmica 29(1), 3–33 (2001)zbMATHMathSciNetCrossRefGoogle Scholar
  29. 29.
    Grübel, R., Rösler, U.: Asymptotic distribution theory for Hoare’s selection algorithm. Adv. Appl. Probab. 28(1), 252–269 (1996)zbMATHCrossRefGoogle Scholar
  30. 30.
    Rösler, U.: QUICKSELECT revisited. J. Iran. Stat. Inst. 3, 271–296 (2004)Google Scholar
  31. 31.
    Grübel, R.: Hoare’s selection algorithm: a Markov chain approach. J. Appl. Probab. 35(1), 36–45 (1998)zbMATHMathSciNetCrossRefGoogle Scholar
  32. 32.
    Hwang, H.K., Tsai, T.H.: Quickselect and Dickman function. Comb. Probab. Comput. 11, 353–371 (2000)Google Scholar
  33. 33.
    Aumüller, M., Dietzfelbinger, M.: Optimal partitioning for dual pivot quicksort (2013).
  34. 34.
    Martínez, C., Panario, D., Viola, A.: Adaptive sampling strategies for quickselects. ACM Trans. Algorithms 6(3), 1–45 (2010)MathSciNetCrossRefGoogle Scholar
  35. 35.
    Martínez, C., Roura, S.: Optimal sampling strategies in quicksort and quickselect. SIAM J. Comput. 31(3), 683 (2001)zbMATHMathSciNetCrossRefGoogle Scholar
  36. 36.
    Wild, S., Nebel, M.E., Reitzig, R., Laube, U.: Engineering Java 7’s dual pivot quicksort using MaLiJAn. In: Sanders, P., Zeh, N. (eds.) ALENEX 2013, pp. 55–69. SIAM (2013)Google Scholar
  37. 37.
    Fill, J.A., Nakama, T.: Analysis of the expected number of bit comparisons required by quickselect. Algorithmica 58(3), 730–769 (2009)MathSciNetCrossRefGoogle Scholar

Copyright information

© Springer Science+Business Media New York 2014

Authors and Affiliations

  • Sebastian Wild
    • 1
  • Markus E. Nebel
    • 1
    • 2
  • Hosam Mahmoud
    • 3
  1. 1.Computer Science DepartmentUniversity of KaiserslauternKaiserslauternGermany
  2. 2.Department of Mathematics and Computer ScienceUniversity of Southern DenmarkOdenseDenmark
  3. 3.Department of StatisticsThe George Washington UniversityWashingtonUSA

Personalised recommendations