arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 1504.01459cs.DScs.CCcs.DM
收藏

一个完整的堆排序最坏情况分析及其结果的实验验证,手稿(MS)

A Complete Worst-Case Analysis of Heapsort with Experimental Verification of Its Results, A manuscript (MS)

Marek A. Suchenek

摘要:

给出了一个严格的证明,证明了在最坏情况下由${\tt Heapsort}$对任何大小为$N \geq 2$的数组执行的密钥比较的次数等于:$ 2 (N-1)\, ( \, \lg \frac{N-1}{2} +\varepsilon \, ) - 2s_2(N) - e_2(N) + \min (\lfloor \lg (N-1) \rfloor, 2) + 6 + c, $其中$ \varepsilon $,由下式给出:$\varepsilon = 1 + \lceil \lg \, (N-1) \rceil - \lg \, (N-1) - 2^{\lceil \lg \, (N-1) \rceil - \lg \, (N-1)} ,$是$ N $的函数,最小值为0,上确界值为$δ= 1 - \lg e + \lg \lg e \approx 0.0860713320559342$,$s_2(N)$是$N$的二进制表示的所有数字的和,$e_2(N)$是$N$的素分解中$2$的指数,$ c $是由下式定义的整数集上的二元函数:如果是$c = 1$,则为$N \leq 2 ^{\lceil \lg N \rceil} - 4$,否则为$c = 0$。提供了一种生成${\tt Heapsort}$的任意大小$ N \geq 2 $的最坏情况输入阵列的算法。该算法已在Java中实现,在$O( N \log N )$时间内运行,并允许对上述公式进行精确的实验验证。

英文摘要:

A rigorous proof is presented that the number of comparisons of keys performed in the worst case by ${\tt Heapsort}$ on any array of size $N \geq 2$ is equal to: $ 2 (N-1)\, ( \, \lg \frac{N-1}{2} +\varepsilon \, ) - 2s_2(N) - e_2(N) + \min (\lfloor \lg (N-1) \rfloor, 2) + 6 + c, $ where $ \varepsilon $, given by: $\varepsilon = 1 + \lceil \lg \, (N-1) \rceil - \lg \, (N-1) - 2^{\lceil \lg \, (N-1) \rceil - \lg \, (N-1)} ,$ is a function of $ N $ with the minimum value 0 and and the supremum value $δ= 1 - \lg e + \lg \lg e \approx 0.0860713320559342$, $s_2(N)$ is the sum of all digits of the binary representation of $N$, $e_2(N)$ is the exponent of $2$ in the prime factorization of $N$, and $ c $ is a binary function on the set of integers defined by: $c = 1$, if $N \leq 2 ^{\lceil \lg N \rceil} - 4$, and $c = 0$, otherwise. An algorithm that generates worst-case input arrays of any size $ N \geq 2 $ for ${\tt Heapsort}$ is offered. The algorithm has been implemented in Java, runs in $O( N \log N )$ time, and allows for precise experimental verification of the above formula.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑