Practical In-Place Mergesort

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 eN log2 N moves, for any fixed e > 0 and any N > N(e). 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.

[1]  Ingo Wegener BOTTOM-UP-HEAPSORT, a New Variant of HEAPSORT, Beating, on an Average, QUICKSORT (if n is not Very Small) , 1993, Theor. Comput. Sci..

[2]  K. Reinhardt Sorting In-Place with a Worst Case Complexity of n log n − 1 . 3 n + O ( log n ) Comparisons and ε n log n + O ( 1 ) Transports ∗ , 1992 .

[3]  Luis I. Trabb-Pardo Stable sorting and merging with optimal space and time bounds. , 1974 .

[4]  Venkatesh Raman,et al.  Sorting with Minimum Data Movement , 1992, J. Algorithms.

[5]  Jeffrey S. Salowe,et al.  Simplified Stable Merging Tasks , 1987, J. Algorithms.

[6]  Svante Carlsson A Variant of Heapsort with Almost Optimal Number of Comparisons , 1987, Inf. Process. Lett..

[7]  Venkatesh Raman Sorting in-place with minimum data movement , 1992 .

[8]  Frank K. Hwang,et al.  A Simple Algorithm for Merging Two Disjoint Linearly-Ordered Sets , 1972, SIAM J. Comput..

[9]  Rudolf Fleischer A Tight Lower Bound for the Worst Case of Bottom-Up Heapsort , 1991, ISA.

[10]  Michael A. Langston,et al.  Practical in-place merging , 1987, CACM.

[11]  Jukka Teuhola,et al.  In-place Linear Probing Sort , 1992, STACS.

[12]  Robert Sedgewick,et al.  The Analysis of Heapsort , 1993, J. Algorithms.

[13]  Jon Louis Bentley,et al.  Engineering a sort function , 1993, Softw. Pract. Exp..

[14]  Klaus Reinhardt Sorting In-Place with a Worst Case Complexity of n log n-1.3n + O(logn) Comparisons and epsilon n log n + O(1) Transports , 1992, ISAAC.