English

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

Data Structures and Algorithms 2017-03-07 v1 Computational Complexity Discrete Mathematics

Abstract

A rigorous proof is presented that the number of comparisons of keys performed in the worst case by Heapsort{\tt Heapsort} on any array of size N2N \geq 2 is equal to: 2(N1)(lgN12+ε)2s2(N)e2(N)+min(lg(N1),2)+6+c, 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: ε=1+lg(N1)lg(N1)2lg(N1)lg(N1),\varepsilon = 1 + \lceil \lg \, (N-1) \rceil - \lg \, (N-1) - 2^{\lceil \lg \, (N-1) \rceil - \lg \, (N-1)} , is a function of N N with the minimum value 0 and and the supremum value δ=1lge+lglge0.0860713320559342\delta = 1 - \lg e + \lg \lg e \approx 0.0860713320559342, s2(N)s_2(N) is the sum of all digits of the binary representation of NN, e2(N)e_2(N) is the exponent of 22 in the prime factorization of NN, and c c is a binary function on the set of integers defined by: c=1c = 1, if N2lgN4N \leq 2 ^{\lceil \lg N \rceil} - 4, and c=0c = 0, otherwise. An algorithm that generates worst-case input arrays of any size N2 N \geq 2 for Heapsort{\tt Heapsort} is offered. The algorithm has been implemented in Java, runs in O(NlogN)O( N \log N ) time, and allows for precise experimental verification of the above formula.

Keywords

Cite

@article{arxiv.1504.01459,
  title  = {A Complete Worst-Case Analysis of Heapsort with Experimental Verification of Its Results, A manuscript (MS)},
  author = {Marek A. Suchenek},
  journal= {arXiv preprint arXiv:1504.01459},
  year   = {2017}
}

Comments

115 pages 41 figures