On Optimal and Efficient in Place Merging

  • Pok-Son Kim
  • Arne Kutzner
Part of the Lecture Notes in Computer Science book series (LNCS, volume 3831)


We introduce a new stable in place merging algorithm that needs O(mlog\((\frac{n}{m}+1))\) comparisons and O(m+n) assignments. According to the lower bounds for merging our algorithm is asymptotically optimal regarding the number of comparisons as well as assignments. The stable algorithm is developed in a modular style out of an unstable kernel for which we give a definition in pseudocode.

The literature so far describes several similar algorithms but merely as sophisticated theoretical models without any reasoning about their practical value. We report specific benchmarks and show that our algorithm is for almost all input sequences faster than the efficient minimum storage algorithm by Dudzinski and Dydek. The proposed algorithm can be effectively used in practice.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Knuth, D.E.: The Art of Computer Programming. Sorting and Searching, vol. 3. Addison-Wesley, Reading (1973)Google Scholar
  2. 2.
    Symvonis, A.: Optimal Stable Merging. Computer Journal 38, 681–690 (1995)CrossRefGoogle Scholar
  3. 3.
    Geffert, V., Katajainen, J., Pasanen, T.: Asymptotically Efficient in-Place Merging. Theoretical Computer Science 237, 159–181 (2000)MATHCrossRefMathSciNetGoogle Scholar
  4. 4.
    Chen, J.: Optimizing Stable in-Place Merging. Theoretical Computer Science 302, 191–210 (2003)MATHCrossRefMathSciNetGoogle Scholar
  5. 5.
    Mannila, H., Ukkonen, E.: A Simple Linear-Time Algorithm for in Situ Merging. Information Processing Letters 18, 203–208 (1984)CrossRefMathSciNetGoogle Scholar
  6. 6.
    Kronrod, M.A.: An Optimal Ordering Algorithm without a Field Operation. Dokladi Akad. Nauk SSSR 186, 1256–1258 (1969)MathSciNetGoogle Scholar
  7. 7.
    Dudzinski, K., Dydek, A.: On a Stable Storage Merging Algorithm. Information Processing Letters 12, 5–8 (1981)MATHCrossRefMathSciNetGoogle Scholar
  8. 8.
    C++ Standard Template Library, http://www.sgi.com/tech/stl
  9. 9.
    Pardo, L.T.: Stable Sorting and Merging with Optimal Space and Time Bounds. SIAM Journal on Computing 6, 351–372 (1977)MATHCrossRefMathSciNetGoogle Scholar
  10. 10.
    Salowe, J., Steiger, W.: Simplified Stable Merging Tasks. Journal of Algorithms 8, 557–571 (1987)MATHCrossRefMathSciNetGoogle Scholar
  11. 11.
    Huang, B.C., Langston, M.: Practical in-Place Merging. Communications of the ACM 31, 348–352 (1988)CrossRefGoogle Scholar
  12. 12.
    Kim, P.S., Kutzner, A.: Stable Minimum Storage Merging by Symmetric Comparisons. In: Albers, S., Radzik, T. (eds.) ESA 2004. LNCS, vol. 3221, pp. 714–723. Springer, Heidelberg (2004)CrossRefGoogle Scholar
  13. 13.
    Hwang, F., Lin, S.: A Simple Algorithm for Merging Two Disjoint Linearly Ordered Sets. SIAM J. Comput. 1, 31–39 (1972)MATHCrossRefMathSciNetGoogle Scholar
  14. 14.
    Cormen, T., Leiserson, C., Rivest, R., Stein, C.: Introduction to Algorithms, 2nd edn. MIT Press, Cambridge (2001)MATHGoogle Scholar
  15. 15.
    Bentley, J.: Programming Pearls, 2nd edn. Addison-Wesley, Inc., Reading (2000)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2006

Authors and Affiliations

  • Pok-Son Kim
    • 1
  • Arne Kutzner
    • 2
  1. 1.Department of MathematicsKookmin UniversitySeoulRep. of Korea
  2. 2.Department of E-BusinessSeokyeong UniversitySeoulRep. of Korea

Personalised recommendations