Practical in-place mergesort

  • Authors:
  • Jyrki Katajainen;Tomi Pasanen;Jukka Teuhola

  • Affiliations:
  • Department of Computer Science, University of Copenhagen, Universitetsparken 1, DK-2100 Copenhagen East, Denmark;Turku Centre for Computer Science, Lemminkäisenkatu 14A, FIN-20520 Turku, Finland;Department of Computer Science, University of Turku, Lemminkäisenkatu 14 A, FIN-20520 Turku, Finland

  • Venue:
  • Nordic Journal of Computing
  • Year:
  • 1996

Quantified Score

Hi-index 0.00

Visualization

Abstract

Two in-place variants of the classical mergesort algorithm are analysed in detail. The first, straightforward variant performs at most N log2 N + O(N) comparisons and 3N log2 N + O(N) moves to sort N elements. The second, more advanced variant requires at most N log2 N + O(N) comparisons and εN log2 N moves, for any fixed ε 0 and any N N(ε). In theory, the second one is superior to advanced versions of heapsort. In practice, due to the overhead in the index manipulation, our fastest in-place mergesort behaves still about 50 per cent slower than the bottom-up heapsort. However, our implementations are practical compared to mergesort algorithms based on in-place merging.