, Volume 9, Issue 6, pp 629–648 | Cite as

Sublinear merging and natural mergesort

  • Svante Carlsson
  • Christos Levcopoulos
  • Ola Petersson


The complexity of merging two sorted sequences into one is linear in the worst case as well as in the average case. There are, however, instances for which a sublinear number of comparisons is sufficient. We consider the problem of measuring and exploiting such instance easiness. The merging algorithm presented, Adaptmerge, is shown to adapt optimally to different kinds of measures of instance easiness. In the sorting problem the concept of instance easiness has received a lot of attention, and it is interpreted by a measure of presortedness. We apply Adaptmerge in the already adaptive sorting algorithm Natural Mergesort. The resulting algorithm, Adaptive Mergesort, optimally adapts to several, known and new, measures of presortedness. We also prove some interesting results concerning the relation between measures of presortedness proposed in the literature.

Key words

Merging Sorting Instance easiness Measures 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. [1]
    K. Mehlhorn.Data Structures and Algorithms, Vol. 1. Springer-Verlag, Berlin, 1984.Google Scholar
  2. [2]
    W. H. Burge. Sorting, trees, and measures of order.Information and Control, 1(3):181–197, 1958.Google Scholar
  3. [3]
    C. R. Cook and D. J. Kim. Best sorting algorithms for nearly sorted lists.Communications of the ACM, 23 (11):620–624, 1980.Google Scholar
  4. [4]
    D. E. Knuth.The Art of Computer Programming, Vol. 3. Addison-Wesley, Reading, Mass., 1973.Google Scholar
  5. [5]
    H. Mannila. Measures of presortedness and optimal sorting algorithms.IEEE Transactions on Computers, 34(4):318–325, 1985.Google Scholar
  6. [6]
    O. Petersson and A. Moffat. A framework for adaptive sorting. InProceedings of the Third Scandinavian Workshop on Algorithm Theory, pp. 422–433. Lecture Notes in Computer Science, Vol. 621, Springer-Verlag, Berlin, 1992.Google Scholar
  7. [7]
    M. L. Fredman. How good is the information theory bound in sorting?Theoretical Computer Science, 1:355–361, 1976.Google Scholar
  8. [8]
    O. Petersson. Adaptive Sorting. Ph.D. thesis, Department of Computer Science, Lund University, Lund, 1990.Google Scholar
  9. [9]
    H. Mannila and E. Ukkonen. A simple linear-time algorithm for in situ merging.Information Processing Letters, 18(4):203–208, 1984.Google Scholar
  10. [10]
    A. Moffat. Adaptive merging and a naturally Natural Merge Sort. InProceedings of the 14th Australian Computer Science Conference, pp. 08.1–08.8, 1991.Google Scholar

Copyright information

© Springer-Verlag New York Inc 1993

Authors and Affiliations

  • Svante Carlsson
    • 1
  • Christos Levcopoulos
    • 2
  • Ola Petersson
    • 2
  1. 1.Department of Computer ScienceLuleå UniversityLuleåSweden
  2. 2.Department of Computer ScienceLund UniversityLundSweden

Personalised recommendations