Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><a href="http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.45.5606&amp;rep=rep1&amp;type=ps" rel="nofollow noreferrer">This</a> seems to indicate that it is possible to do in O(lg^2 n) space. I cannot see how to prove that it is impossible to merge in constant space, but I cannot see how to do it either.</p> <p>Edit: Chasing references, Knuth Vol 3 - Exercise 5.5.3 says "A considerably more complicated algorithm of L. Trabb-Pardo provides the best possible answer to this problem: It is possible to do stable merging in O(n) time and stable sorting in O(n lg n) time, using only O(lg n) bits of auxiliary memory for a fixed number of index variables.</p> <p>More <a href="http://comjnl.oxfordjournals.org/cgi/reprint/35/6/643.pdf" rel="nofollow noreferrer">references</a> that I have not read. Thanks for an interesting problem.</p> <p>Further edit: This article claims that the article by Huang and Langston have an algorithm that merges two lists of size m and n in time O(m + n), so the answer to your question would seem to be yes. Unfortunately I do not have access to the article, so I must trust the second hand information. I'm not sure how to reconcile this with Knuth's pronouncement that the Trabb-Pardo algorithm is optimal. If my life depended on it, I'd go with Knuth.</p> <p>I now see that this had been asked as and earlier Stack Overflow <a href="https://stackoverflow.com/questions/2126219/how-to-merge-two-sorted-integer-array-in-place-using-on-time-and-o1-space-cos">question</a> a <a href="https://stackoverflow.com/questions/2571049/how-to-sort-in-place-using-the-merge-sort-algorithm">number</a> of times. I don't have the heart to flag it as a duplicate.</p> <p>Huang B.-C. and Langston M. A., Practical in-place merging, Comm. ACM 31 (1988) 348-352</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload