Skip Navigation

The Computer Journal 2000 43(1):40-53; doi:10.1093/comjnl/43.1.40
© 2000 by British Computer Society
This Article
Right arrow Full Text (PDF)
Right arrow Alert me when this article is cited
Right arrow Alert me if a correction is posted
Services
Right arrow Email this article to a friend
Right arrow Similar articles in this journal
Right arrow Similar articles in ISI Web of Science
Right arrow Alert me to new issues of the journal
Right arrow Add to My Personal Archive
Right arrow Download to citation manager
Right arrow Search for citing articles in:
ISI Web of Science (3)
Right arrowRequest Permissions
Google Scholar
Right arrow Articles by Ellis, J.
Right arrow Articles by Markov, M.
Right arrow Search for Related Content
Social Bookmarking
 Add to CiteULike   Add to Connotea   Add to Del.icio.us  
What's this?

In situ, Stable Merging by Way of the Perfect Shuffle

John Ellis1 and Minko Markov1

1 Department of Computer Science, University of Victoria, PO Box 3055, Victoria, British Columbia, V8W 3P6, Canada Email: jellis@csr.uvic.ca

We introduce a novel approach to the classical problem of the in situ, stable merging of lists, where ‘in situ means the use of no more than $O(\log^2 n)$ bits of extra memory for lists of size $n$. Our algorithm, Shufflemerge, reduces the merging problem to the problem of realizing the ‘perfect shuffle’ permutation, that is, the exact interleaving of two, equal length lists. The algorithm is recursive and so uses a logarithmic number of variables. Thus it uses more than ‘absolutely minimum storage’, i.e. $O(\log n)$ bits. A simple method of realizing the perfect shuffle uses one extra bit per element, and so is not in situ. We show that the perfect shuffle can be attained using absolutely minimum storage and in linear time, at the expense of doubling the number of moves, relative to the simple method. We note that there is a worst case for Shufflemerge requiring time $\Omega(n \log n)$, where $n$ is the sum of the lengths of the input lists. We also present an analysis of a variant of Shufflemerge which uses a generalized shuffle and which has a provable average case time complexity of $O(n\log \log m)$, where $m$ is the length of the shortest input list. It is unlikely that the generalized shuffle can be achieved in situ. Linear time, in situ, stable merging has previously been demonstrated. We present experimental evidence indicating that Shufflemerge, although almost certainly not asymptotically linear, might be of value in practice. The relative simplicity of the basic method, particularly with respect to stability, also recommends it.


Received 7 May, 1998. Revised 1 November, 1999.


Add to CiteULike CiteULike   Add to Connotea Connotea   Add to Del.icio.us Del.icio.us    What's this?




Disclaimer:
Please note that abstracts for content published before 1996 were created through digital scanning and may therefore not exactly replicate the text of the original print issues. All efforts have been made to ensure accuracy, but the Publisher will not be held responsible for any remaining inaccuracies. If you require any further clarification, please contact our Customer Services Department.