ArticlePublisher preview available

# QuickHeapsort: Modifications and Improved Analysis

Authors:
To read the full-text of this research, you can request a copy directly from the authors.

## Abstract and Figures

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 modifications of QuickHeapsort. We show that for every input the expected number of comparisons is at most nlog2n−0.03n+o(n)\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$n\log _{2}n - 0.03n + o(n)$\end{document} for the in-place variant. If we allow n extra bits, then we can lower the bound to nlog2n−0.997n+o(n)\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$n\log _{2} n -0.997 n+ o (n)$\end{document}. Thus, spending n extra bits we can save more that 0.96n comparisons if n is 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 variants and Relaxed-Weak-Heapsort which use nlog2n−0.9n+o(n)\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$n\log _{2}n -0.9 n+ o (n)$\end{document} comparisons in the worst case. However, index based Heapsort variants and Relaxed-Weak-Heapsort require Θ(nlogn)\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}${\Theta }(n\log n)$\end{document} extra bits whereas we need n bits 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.
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
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 nlog2n0.03n+o(n) for the in-place variant. If we allow
nextra bits, then we can lower the bound to nlog2n0.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 nlog2n0.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