A meticulous analysis of mergesort programs (original) (raw)

Abstract

The efficiency of mergesort programs is analysed under a simple unit-cost model. In our analysis the time performance of the sorting programs includes the costs of key comparisons, element moves and address calculations. The goal is to establish the best possible time-bound relative to the model when sorting n integers. By the well-known information-theoretic argument n log2 n−O(n) is a lower bound for the integer-sorting problem in our framework. New implementations for two-way and four-way bottom-up mergesort are given, the worst-case complexities of which are shown to be bounded by 5.5_n_ log2 n+O(n) and 3.25_n_ log2 n+O(n), respectively. The theoretical findings are backed up with a series of experiments which show the practical relevance of our analysis when implementing library routines for internal-memory computations.

Supported partially by the Danish Natural Science Research Council under contract No. 9400952 (project “Computational Algorithmics”).

Preview

Unable to display preview. Download preview PDF.

Similar content being viewed by others

References

  1. A. Andersson, T. Hagerup, S. Nilsson, and R. Raman, Sorting in linear time?, in Proceedings of the 27th Annual ACM Symposium on the Theory of Computing, ACM Press, New York, N.Y., 1995, pp. 427–436.
    Google Scholar
  2. S. Baase, Computer Algorithms: Introduction to Design and Analysis, 2nd Edition, Addison-Wesley Publishing Company, Reading, Mass., 1988.
    Google Scholar
  3. J. L. Bentley, B. W. Kernighan, and C. J. van Wyk, An elementary C cost model, UNIX Review 9 (1991) 38–48.
    Google Scholar
  4. S. Carlsson, Average-case results on Heapsort, BIT 27 (1987) 2–17.
    Google Scholar
  5. V. Estivill-Castro and D. Wood, A survey of adaptive sorting algorithms, ACM Computing Surveys 24 (1992) 441–476.
    Google Scholar
  6. H. H. Goldstine and J. von Neumann, Planning and coding of problems for an electronic computing instrument, Part II, Volume 2, reprinted in John von Neumann Collected Works, Volume V: Design of Computers, Theory of Automata and Numerical Analysis, Pergamon Press, Oxford, England, 1963, pp. 152–214.
    Google Scholar
  7. M. J. Golin and R. Sedgewick, Queue-mergesort, Information Processing Letters 48 (1993) 253–259.
    Google Scholar
  8. J. Katajainen, T. Pasanen, and J. Teuhola, Practical in-place mergesort, Nordic Journal of Computing, 3 (1996) 27–40.
    Google Scholar
  9. B.W. Kernighan and D.M. Ritchie, The C Programming Language, 2nd Edition. Prentice-Hall, Englewood Cliffs, N.J., 1988.
    Google Scholar
  10. D.E. Knuth, The Art of Computer Programming, Volume 1: Fundamental Algorithms, Addison-Wesley Publishing Company, Reading, Mass., 1968.
    Google Scholar
  11. D. E. Knuth, The Art of Computer Programming, Volume 3: Sorting and Searching, Addison-Wesley Publishing Company, Reading, Mass., 1973.
    Google Scholar
  12. D. E. Knuth, Axioms and Hulls, Lecture Notes in Computer Science 606, Springer-Verlag, Berlin/Heidelberg, Germany, 1992.
    Google Scholar
  13. D. E. Knuth, The Stanford GraphBase: A Platform for Combinatorial Computing, Addison-Wesley Publishing Company, Reading, Mass., 1993.
    Google Scholar
  14. A. M. Moffat and O. Petersson, An overview of adaptive sorting, The Australian Computer Journal 24 (1992) 70–77.
    Google Scholar
  15. D.A.Patterson and J. L. Hennessy, Computer Organization & Design: The Hardware/Software Interface, Morgan Kaufmann Publishers, San Francisco, Calif., 1994.
    Google Scholar
  16. R. Sedgewick, Implementing Quicksort programs, Communications of the ACM 21 (1978) 847–857. Corrigendum ibidem 23 (79) 368.
    Google Scholar
  17. R. Sedgewick, Algorithms, 2nd Edition, Addison-Wesley Publishing Company, Reading, Mass., 1988.
    Google Scholar

Download references

Author information

Authors and Affiliations

  1. Department of Computer Science, University of Copenhagen, Universitetsparken 1, DK-2100, Copenhagen East, Denmark
    Jyrki Katajainen
  2. Max-Planck-Institut für Informatik, Im Stadtwald, D-66123, Saarbrücken, Germany
    Jesper Larsson Träff

Editor information

Giancarlo Bongiovanni Daniel Pierre Bovet Giuseppe Di Battista

Rights and permissions

© 1997 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Katajainen, J., Träff, J.L. (1997). A meticulous analysis of mergesort programs. In: Bongiovanni, G., Bovet, D.P., Di Battista, G. (eds) Algorithms and Complexity. CIAC 1997. Lecture Notes in Computer Science, vol 1203. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-62592-5\_74

Download citation

Keywords

These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Publish with us