Optimal sampling strategies in quicksort

被引:0
|
作者
Martínez, C [1 ]
Roura, S [1 ]
机构
[1] Univ Politecn Catalunya, Dept Llenguatges & Sistemes Informat, E-08034 Barcelona, Catalonia, Spain
来源
关键词
D O I
暂无
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
It is well known that the performance of quicksort can be substantially improved by selecting the median of a sample of three elements as the pivot of each partitioning stage. This variant is easily generalized to samples of size s = 2k + 1. For large samples the partitions are better as the median of the sample makes a more accurate estimate of the median of the array to be sorted, but the amount of additional comparisons and exchanges to find the median of the sample also increases. We show that the optimal sample size to minimize the average total cost of quicksort (which includes both comparisons and exchanges) is s = a . root n + o(root n). We also give a closed expression for the constant factor a, which depends on the median-finding algorithm and the costs of elementary comparisons and exchanges. The result above holds in most situations, unless the cost of an exchange exceeds by far the cost of a comparison. In that particular case, it is better to select not the median of the samples, but the (p + 1)(th) element. The value of p can be precisely determined as a function of the ratio between the cost of an exchange and the cost of a comparison.
引用
收藏
页码:327 / 338
页数:12
相关论文
共 50 条
  • [1] OPTIMAL SAMPLING STRATEGIES FOR QUICKSORT
    MCGEOCH, CC
    TYGAR, JD
    RANDOM STRUCTURES & ALGORITHMS, 1995, 7 (04) : 287 - 300
  • [2] Optimal sampling strategies in quicksort and quickselect
    Martínez, C
    Roura, S
    SIAM JOURNAL ON COMPUTING, 2002, 31 (03) : 683 - 705
  • [3] OPTIMAL PARALLEL QUICKSORT ON EREW PRAM
    ZHANG, WX
    RAO, NSV
    BIT, 1991, 31 (01): : 69 - 74
  • [4] OPTIMAL SAMPLING STRATEGIES FOR VALIDATION STUDIES
    OSBURN, HG
    GREENER, JM
    JOURNAL OF APPLIED PSYCHOLOGY, 1978, 63 (05) : 602 - 608
  • [5] Epipolar spaces and optimal sampling strategies
    Monaco, James
    Bovik, Alan C.
    Cormack, Lawrence K.
    2007 IEEE INTERNATIONAL CONFERENCE ON IMAGE PROCESSING, VOLS 1-7, 2007, : 3341 - +
  • [7] Optimal Partitioning for Dual Pivot Quicksort
    Aumueller, Martin
    Dietzfelbinger, Martin
    AUTOMATA, LANGUAGES, AND PROGRAMMING, PT I, 2013, 7965 : 33 - 44
  • [8] Optimal Partitioning for Dual-Pivot Quicksort
    Aumueller, Martin
    Dietzfelbinger, Martin
    ACM TRANSACTIONS ON ALGORITHMS, 2016, 12 (02)
  • [9] A cost optimal parallel quicksort on CREW PRAM
    Liu, H
    He, J
    COMPUTERS AND THEIR APPLICATIONS, 2003, : 13 - 16
  • [10] MONOTONE OPTIMAL STRATEGIES FOR A SEQUENTIAL SAMPLING PROBLEM
    KALIN, D
    ZEITSCHRIFT FUR ANGEWANDTE MATHEMATIK UND MECHANIK, 1981, 61 (05): : T337 - T338