Worst-Case Analysis of Heapsort, Exactly

被引:0
|
作者
Suchenek, Marek A. [1 ]
机构
[1] Calif State Univ Dominguez Hills, Dept Comp Sci, 1000 E Victoria St, Carson, CA 90747 USA
来源
COMPUTER JOURNAL | 2024年 / 67卷 / 03期
关键词
heap; heapsort; sorting; sum of digits; worst case;
D O I
10.1093/comjnl/bxad007
中图分类号
TP3 [计算技术、计算机技术];
学科分类号
0812 ;
摘要
This paper completes analysis of the worst-case running time of $ {\tt{Heapsort}}$ measured by the number of comparisons of keys performed while sorting. A derivation of an exact formula for the maximum number of comparisons of keys performed by $ {\tt{Heapsort}} $ on any array of size $ N \geq 2 $ is presented. It is equal to $$ \begin{align}& \nonumber 2(N-1)\lceil \lg N \rceil - 2 <^>{\lceil \lg N \rceil +1} - 2 s_2(N) - e_2(N) + \min (\lceil \lg N \rceil, 3) + 5 + c, \end{align} $$ where $s_2(N)$ is the sum of digits of the binary representation of $N$, $e_2(N)$ is the exponent of $2$ in the $N$'s prime factorization and $ c $ is a binary function on the set of positive integers defined by $$ \begin{align}& \nonumber c = \left\{ \begin{array}{@{}ll} 1 \text{ if} \; N \leq 2 <^>{\lceil \lg N \rceil} - 4 \\[4pt] 0 \text{ otherwise}. \end{array} \right. \end{align} $$ The above formula allows for deciding, in $ O(N \log N) $ time, if any given $ N $-element array is a worst-case array for $ {\tt{Heapsort}} $. Its proof yields an algorithm for construction, in $ O(N \log N) $ time, of worst-case arrays of arbitrary sizes $ N \geq 2 $ for $ {\tt{Heapsort}} $.
引用
收藏
页码:812 / 824
页数:13
相关论文
共 50 条
  • [21] Obstacles in worst-case execution time analysis
    Kirner, Raimund
    Puschner, Peter
    ISORC 2008: 11TH IEEE SYMPOSIUM ON OBJECT/COMPONENT/SERVICE-ORIENTED REAL-TIME DISTRIBUTED COMPUTING - PROCEEDINGS, 2008, : 333 - 339
  • [22] WORST-CASE ANALYSIS OF SET UNION ALGORITHMS
    TARJAN, RE
    VANLEEUWEN, J
    JOURNAL OF THE ACM, 1984, 31 (02) : 245 - 281
  • [23] The worst-case analysis of the Garey–Johnson algorithm
    Claire Hanen
    Yakov Zinder
    Journal of Scheduling, 2009, 12 : 389 - 400
  • [24] The worst-case scenario
    Schneider, Stephen
    NATURE, 2009, 458 (7242) : 1104 - 1105
  • [25] Worst-case scenarios
    Wilkinson, T. M.
    RES PUBLICA-A JOURNAL OF MORAL LEGAL AND POLITICAL PHILOSOPHY, 2009, 15 (02): : 203 - 211
  • [26] WORST-CASE ANALYSIS OF AN ALGORITHM FOR CELLULAR MANUFACTURING
    NG, SM
    EUROPEAN JOURNAL OF OPERATIONAL RESEARCH, 1993, 69 (03) : 384 - 398
  • [27] Worst-case distribution analysis of stochastic programs
    Alexander Shapiro
    Mathematical Programming, 2006, 107 : 91 - 96
  • [28] Ties in Worst-Case Analysis of the Euclidean Algorithm
    Hopkins, Brian
    Tangboonduangjit, Aram
    MATHEMATICAL COMMUNICATIONS, 2021, 26 (01) : 9 - 20
  • [29] Worst-case scenarios
    Durodie, Bill
    INTERNATIONAL AFFAIRS, 2008, 84 (03) : 567 - 568
  • [30] Worst-case equilibria
    Koutsoupias, E
    Papadimitriou, C
    STACS'99 - 16TH ANNUAL SYMPOSIUM ON THEORETICAL ASPECTS OF COMPUTER SCIENCE, 1999, 1563 : 404 - 413