skip to main content
research-article

Adaptive sampling strategies for quickselects

Published:02 July 2010Publication History
Skip Abstract Section

Abstract

Quickselect with median-of-3 is largely used in practice and its behavior is fairly well understood. However, the following natural adaptive variant, which we call proportion-from-3, had not been previously analyzed: “choose as pivot the smallest of the sample if the relative rank of the sought element is below 1/3, the largest if the relative rank is above 2/3, and the median if the relative rank is between 1/3 and 2/3.” We first analyze the average number of comparisons made when using proportion-from-2 and then for proportion-from-3. We also analyze ν-find, a generalization of proportion-from-3 with interval breakpoints at ν and 1-ν. We show that there exists an optimal value of ν and we also provide the range of values of ν where ν-find outperforms median-of-3. Then, we consider the average total cost of these strategies, which takes into account the cost of both comparisons and exchanges. Our results strongly suggest that a suitable implementation of ν-find could be the method of choice in a practical setting. We also study the behavior of proportion-from-s with s>3 and in particular we show that proportion-from-s-like strategies are optimal when s→∞.

References

  1. Anderson, D. and Brown, R. 1992. Combinatorial aspects of C.A.R. Hoare's Find algorithm. Australasian J. Combin. 5, 109--119.Google ScholarGoogle Scholar
  2. Bentley, J. and McIlroy, M. 1993. Engineering a sort function. Softw. Pract. Exper. 23, 1249--1265. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Bleistein, N. and Handelsman, R. A. 1975. Asymptotic Expansions of Integrals. Dover, New York.Google ScholarGoogle Scholar
  4. Cunto, W. and Munro, J. 1989. Average case selection. J. Assoc. Comput. Mach. 36, 2, 270--279. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Daligault, J. and Martínez, C. 2006. On the variance of quickselect. In Proceedings of the 8th ACM-SIAM Workshop on Algorithm Engineering and Experimennts (ALENEX) and the 3rd ACM-SIAM Workshop on Analytic Algorithmics and Cominatorics (ANALCO). R. Raman, R. Sedgewick, and M. Stallmann, Eds. SIAM, 205--210.Google ScholarGoogle Scholar
  6. Floyd, R. and Rivest, R. 1975. Expected time bounds for selection. Comm. ACM 18, 3, 165--173. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Graham, R., Knuth, D., and Patashnik, O. 1994. Concrete Mathematics, 2nd Ed. Addison-Wesley, Reading, MA.Google ScholarGoogle Scholar
  8. Grübel, R. 1999. On the median-of-k version of Hoare's selection algorithm.Theor. Inform. Appl. 33, 2, 177--192.Google ScholarGoogle ScholarCross RefCross Ref
  9. Grübel, R. and Rösler, U. 1996. Asymptotic distribution theory for Hoare's selection algorithm. Adv. Appl. Probab. 28, 252--269.Google ScholarGoogle ScholarCross RefCross Ref
  10. Hoare, C. 1961. Find (Algorithm 65). Commun. ACM 4, 321--322. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Hoare, C. 1962. Quicksort. Comput. J. 5, 10--15.Google ScholarGoogle ScholarCross RefCross Ref
  12. Kirschenhofer, P. and Prodinger, H. 1998. Comparisons in Hoare's Find algorithm. Combin. Probab. Comput. 7, 111--120. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Kirschenhofer, P., Prodinger, H., and Martínez, C. 1997. Analysis of Hoare's Find algorithm with median-of-three partition. Ramdom Struct. Algor 10, 1, 143--156. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Knof, D. and Rösler, U. 2007. The analysis of Find or perpetuities on Cadlag functions. Submitted to Discr. Math Theor. Comput. Sci.Google ScholarGoogle Scholar
  15. Knuth, D. 1972. Mathematical analysis of algorithms. In Proceedings of the IFIP Congress Information Processing'71. North-Holland, Amsterdam, 19--27.Google ScholarGoogle Scholar
  16. Knuth, D. 1998. The Art of Computer Programming: Sorting and Searching 2nd Ed. Vol. 3. Addison-Wesley, Reading, MA. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Mahmoud, H. 2000. Sorting: A Distribution Theory. John Wiley & Sons, New York.Google ScholarGoogle ScholarCross RefCross Ref
  18. Mahmoud, H. and Pittel, B. 1989. Analysis of the space of search trees under the random insertion algorithm. J. Algor. 10, 52--75. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Martínez, C., Panario, D., and Viola, A. 2004. Adaptive sampling for quickselect. In Proceedings of the 15th Annual ACM-SIAM symposium on Discreate Algorithms (SODA). SIAM, 440--448. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Martínez, C. and Roura, S. 2001. Optimal sampling strategies in quicksort and quickselect. SIAM J. Comput. 31, 3, 683--705. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Musser, D. 1997. Introspective sorting and selection algorithms. Softw. Pract. Exper. 27, 8, 983--993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Panholzer, A. 2003. Analysis of multiple quickselect variants. Theoret. Comput. Sci. 302, 1--3, 45--91. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Petkovsek, M., Wilf, H. S., and Zeilberger, D. 1996. A = B. A. K. Peters, Wellesley, MA. http://www.math.upenn.edu/~wilf/Downld.html.Google ScholarGoogle Scholar
  24. Rainville, E., Bedient, P., and Bedient, R. 1997. Elementary Differential Equations 8th Ed. Prentice Hall.Google ScholarGoogle Scholar
  25. Sedgewick, R. 1978. Quicksort. Garland, New York.Google ScholarGoogle Scholar
  26. Whittaker, E. and Watson, G. 1927. A Course of Modern Analysis, 4th Ed. Cambridge University Press.Google ScholarGoogle Scholar

Index Terms

  1. Adaptive sampling strategies for quickselects

    Recommendations

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in

    Full Access

    • Published in

      cover image ACM Transactions on Algorithms
      ACM Transactions on Algorithms  Volume 6, Issue 3
      June 2010
      304 pages
      ISSN:1549-6325
      EISSN:1549-6333
      DOI:10.1145/1798596
      Issue’s Table of Contents

      Copyright © 2010 ACM

      Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 2 July 2010
      • Revised: 1 January 2008
      • Accepted: 1 January 2008
      • Received: 1 August 2007
      Published in talg Volume 6, Issue 3

      Permissions

      Request permissions about this article.

      Request Permissions

      Check for updates

      Qualifiers

      • research-article
      • Research
      • Refereed

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader