How to sort in-place using the merge sort algorithm?

前端 未结 10 1624
心在旅途
心在旅途 2020-11-22 02:21

I know the question is not too specific.

All I want is someone to tell me how to convert a normal merge sort into an in-place merge sort (or a merge sort with const

10条回答
  •  广开言路
    2020-11-22 03:05

    Including its "big result", this paper describes a couple of variants of in-place merge sort (PDF):

    http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.22.5514&rep=rep1&type=pdf

    In-place sorting with fewer moves

    Jyrki Katajainen, Tomi A. Pasanen

    It is shown that an array of n elements can be sorted using O(1) extra space, O(n log n / log log n) element moves, and n log2n + O(n log log n) comparisons. This is the first in-place sorting algorithm requiring o(n log n) moves in the worst case while guaranteeing O(n log n) comparisons, but due to the constant factors involved the algorithm is predominantly of theoretical interest.

    I think this is relevant too. I have a printout of it lying around, passed on to me by a colleague, but I haven't read it. It seems to cover basic theory, but I'm not familiar enough with the topic to judge how comprehensively:

    http://comjnl.oxfordjournals.org/cgi/content/abstract/38/8/681

    Optimal Stable Merging

    Antonios Symvonis

    This paper shows how to stably merge two sequences A and B of sizes m and n, m ≤ n, respectively, with O(m+n) assignments, O(mlog(n/m+1)) comparisons and using only a constant amount of additional space. This result matches all known lower bounds...

提交回复
热议问题