- A preview of this full-text is provided by Springer Nature.
- Learn more

Preview content only

Content available from Theory of Computing Systems

This content is subject to copyright. Terms and conditions apply.

Theory Comput Syst (2016) 59:209–230

DOI 10.1007/s00224-015-9656-y

QuickHeapsort: Modifications and Improved Analysis

Volker Diekert1·Armin Weiß1

Published online: 15 September 2015

© Springer Science+Business Media New York 2015

Abstract QuickHeapsort is a combination of Quicksort and Heapsort. We show that

the expected number of comparisons for QuickHeapsort is always better than for

Quicksort if a usual median-of-constant strategy is used for choosing pivot elements.

In order to obtain the result we present a new analysis for QuickHeapsort splitting

it into the analysis of the partition-phases and the analysis of the heap-phases. This

enables us to consider samples of non-constant size for the pivot selection and leads

to better theoretical bounds for the algorithm. Furthermore, we introduce some mod-

ifications of QuickHeapsort. We show that for every input the expected number of

comparisons is at most nlog2n−0.03n+o(n) for the in-place variant. If we allow

nextra bits, then we can lower the bound to nlog2n−0.997n+o(n). Thus, spend-

ing nextra bits we can save more that 0.96ncomparisons if nis large enough. Both

estimates improve the previously known results. Moreover, our non-in-place variant

does essentially use the same number of comparisons as index based Heapsort vari-

ants and Relaxed-Weak-Heapsort which use nlog2n−0.9n+o(n) comparisons in

the worst case. However, index based Heapsort variants and Relaxed-Weak-Heapsort

require (n log n) extra bits whereas we need nbits only. Our theoretical results are

upper bounds and valid for every input. Our computer experiments show that the

gap between our bounds and the actual values on random inputs is small. Moreover,

the computer experiments establish QuickHeapsort as competitive with Quicksort in

terms of running time.

Keywords In-place sorting ·Heapsort ·Quicksort ·Analysis of algorithms

Armin Weiß

armin.weiss@fmi.uni-stuttgart.de

Volker Diekert

diekert@fmi.uni-stuttgart.de

1FMI, Universit¨

at Stuttgart, Universit¨

atsstr. 38, D-70569 Stuttgart, Germany

Content courtesy of Springer Nature, terms of use apply. Rights reserved.