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→∞.
- Anderson, D. and Brown, R. 1992. Combinatorial aspects of C.A.R. Hoare's Find algorithm. Australasian J. Combin. 5, 109--119.Google Scholar
- Bentley, J. and McIlroy, M. 1993. Engineering a sort function. Softw. Pract. Exper. 23, 1249--1265. Google ScholarDigital Library
- Bleistein, N. and Handelsman, R. A. 1975. Asymptotic Expansions of Integrals. Dover, New York.Google Scholar
- Cunto, W. and Munro, J. 1989. Average case selection. J. Assoc. Comput. Mach. 36, 2, 270--279. Google ScholarDigital Library
- 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 Scholar
- Floyd, R. and Rivest, R. 1975. Expected time bounds for selection. Comm. ACM 18, 3, 165--173. Google ScholarDigital Library
- Graham, R., Knuth, D., and Patashnik, O. 1994. Concrete Mathematics, 2nd Ed. Addison-Wesley, Reading, MA.Google Scholar
- Grübel, R. 1999. On the median-of-k version of Hoare's selection algorithm.Theor. Inform. Appl. 33, 2, 177--192.Google ScholarCross Ref
- Grübel, R. and Rösler, U. 1996. Asymptotic distribution theory for Hoare's selection algorithm. Adv. Appl. Probab. 28, 252--269.Google ScholarCross Ref
- Hoare, C. 1961. Find (Algorithm 65). Commun. ACM 4, 321--322. Google ScholarDigital Library
- Hoare, C. 1962. Quicksort. Comput. J. 5, 10--15.Google ScholarCross Ref
- Kirschenhofer, P. and Prodinger, H. 1998. Comparisons in Hoare's Find algorithm. Combin. Probab. Comput. 7, 111--120. Google ScholarDigital Library
- 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 ScholarDigital Library
- Knof, D. and Rösler, U. 2007. The analysis of Find or perpetuities on Cadlag functions. Submitted to Discr. Math Theor. Comput. Sci.Google Scholar
- Knuth, D. 1972. Mathematical analysis of algorithms. In Proceedings of the IFIP Congress Information Processing'71. North-Holland, Amsterdam, 19--27.Google Scholar
- Knuth, D. 1998. The Art of Computer Programming: Sorting and Searching 2nd Ed. Vol. 3. Addison-Wesley, Reading, MA. Google ScholarDigital Library
- Mahmoud, H. 2000. Sorting: A Distribution Theory. John Wiley & Sons, New York.Google ScholarCross Ref
- Mahmoud, H. and Pittel, B. 1989. Analysis of the space of search trees under the random insertion algorithm. J. Algor. 10, 52--75. Google ScholarDigital Library
- 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 ScholarDigital Library
- Martínez, C. and Roura, S. 2001. Optimal sampling strategies in quicksort and quickselect. SIAM J. Comput. 31, 3, 683--705. Google ScholarDigital Library
- Musser, D. 1997. Introspective sorting and selection algorithms. Softw. Pract. Exper. 27, 8, 983--993. Google ScholarDigital Library
- Panholzer, A. 2003. Analysis of multiple quickselect variants. Theoret. Comput. Sci. 302, 1--3, 45--91. Google ScholarDigital Library
- 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 Scholar
- Rainville, E., Bedient, P., and Bedient, R. 1997. Elementary Differential Equations 8th Ed. Prentice Hall.Google Scholar
- Sedgewick, R. 1978. Quicksort. Garland, New York.Google Scholar
- Whittaker, E. and Watson, G. 1927. A Course of Modern Analysis, 4th Ed. Cambridge University Press.Google Scholar
Index Terms
- Adaptive sampling strategies for quickselects
Recommendations
Optimal Sampling Strategies in Quicksort and Quickselect
It is well known that the performance of quicksort can be improved by selecting the median of a sample of elements as the pivot of each partitioning stage. For large samples the partitions are better, but the amount of additional comparisons and ...
Halfspace sampling in evolution strategies
GECCO '14: Proceedings of the 2014 Annual Conference on Genetic and Evolutionary ComputationThis paper presents a novel halfspace sampling method in single parent elitist evolution strategies (ESs) for unimodal functions. In halfspace sampling, the supporting hyperplane going through a parent separates the search space into a positive ...
Analysis of Quickselect Under Yaroslavskiy's Dual-Pivoting Algorithm
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 ...
Comments