A Tight Bound on the Worst-Case Number of Comparisons for Floyd’s Heap Construction Algorithm
In this paper a tight bound on the worst-case number of comparisons for Floyd’s well-known heap construction algorithm is derived.1 It is shown that at most \(2n - 2\mu (n) - \sigma (n)\) comparisons are executed in the worst case, where μ(n) is the number of ones and σ(n) is the number of zeros after the last one in the binary representation of the number of keys n.
Key wordsAlgorithm analysis Worst case complexity Data structures Heaps
- 5.Knuth, D.: The art of computer programming, vol. 3, 2nd edn. Searching and Sorting. Addison Wesley, Redwood city (1998)Google Scholar
- 6.Kruskal, C.P., Weixelbaum, D.: The worst case analysis of heapsort. Technical Report no 018a, Department of Computer Science, New York University (1979)Google Scholar
- 7.Paparrizos, I.: A tight bound on the worst-case number of comparisons for Floyd’s heap construction algorithm. In: Proceedings of the 37th International Conference on Current Trends in Theory and Practice of Computer Science (2011)Google Scholar
- 8.Schaffer, R.: Analysis of heapsort. Ph.D. Thesis, Department of computer science, Princeton University (1992)Google Scholar
- 9.Williams, J.W.J.: Algorithm 232: heapsort. Comm. ACM 6, 347–348 (1964)Google Scholar