Skip to main content

On the Average Case of MergeInsertion

  • Conference paper
  • First Online:

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 11638))

Abstract

MergeInsertion, also known as the Ford-Johnson algorithm, is a sorting algorithm which, up to today, for many input sizes achieves the best known upper bound on the number of comparisons. Indeed, it gets extremely close to the information-theoretic lower bound. While the worst-case behavior is well understood, only little is known about the average case. This work takes a closer look at the average case behavior. In particular, we establish an upper bound of \(n \log n - 1.4005n + o(n)\) comparisons. We also give an exact description of the probability distribution of the length of the chain a given element is inserted into and use it to approximate the average number of comparisons numerically. Moreover, we compute the exact average number of comparisons for n up to 148. Furthermore, we experimentally explore the impact of different decision trees for binary insertion. To conclude, we conduct experiments showing that a slightly different insertion order leads to a better average case and we compare the algorithm to the recent combination with (1,2)-Insertionsort by Iwama and Teruyama.

The second author has been supported by the German Research Foundation (DFG) under grant DI 435/7-1.

This is a preview of subscription content, log in via an institution.

Buying options

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   59.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   79.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

References

  1. Boehm, H.J., Atkinson, R., Plass, M.: Ropes: an alternative to strings. Softw. Pract. Exper. 25(12), 1315–1330 (1995)

    Article  Google Scholar 

  2. Bui, T., Thanh, M.: Significant improvements to the Ford-Johnson algorithm for sorting. BIT Numer. Math. 25(1), 70–75 (1985)

    Article  MathSciNet  Google Scholar 

  3. Edelkamp, S., Weiß, A.: QuickXsort: efficient sorting with n log \({n}-1.399{n}+{o}({n})\) comparisons on average. In: Hirsch, E.A., Kuznetsov, S.O., Pin, J.É., Vereshchagin, N.K. (eds.) CSR 2014. LNCS, vol. 8476, pp. 139–152. Springer, Cham (2014). https://doi.org/10.1007/978-3-319-06686-8_11

    Google Scholar 

  4. Edelkamp, S., Weiß, A., Wild, S.: Quickxsort - A fast sorting scheme in theory and practice. CoRR abs/1811.01259 (2018)

    Google Scholar 

  5. Ford, L.R., Johnson, S.M.: A tournament problem. Am. Math. Monthly 66(5), 387–389 (1959)

    Article  MathSciNet  Google Scholar 

  6. Iwama, K., Teruyama, J.: Improved average complexity for comparison-based sorting. Algorithms and Data Structures. LNCS, vol. 10389, pp. 485–496. Springer, Cham (2017). https://doi.org/10.1007/978-3-319-62127-2_41

    Chapter  Google Scholar 

  7. Knuth, D.E.: The Art of Computer Programming. Sorting and Searching, 2nd Edn, vol. 3. Addison Wesley Longman, Redwood City (1998)

    Google Scholar 

  8. Manacher, G.K.: The Ford-Johnson sorting algorithm is not optimal. J. ACM 26(3), 441–456 (1979)

    Article  MathSciNet  Google Scholar 

  9. Peczarski, M.: New results in minimum-comparison sorting. Algorithmica 40(2), 133–145 (2004)

    Article  MathSciNet  Google Scholar 

  10. Peczarski, M.: The Ford-Johnson algorithm still unbeaten for less than 47 elements. Inf. Process. Lett. 101(3), 126–128 (2007)

    Article  MathSciNet  Google Scholar 

  11. Reinhardt, K.: Sorting in-place with a worst case complexity of n log n-1.3n + O(logn) comparisons and epsilon n log n + O(1) transports. In: Proceedings of Algorithms and Computation, ISAAC 1992, pp. 489–498 (1992)

    Chapter  Google Scholar 

  12. Stober, F.: Source code and generated data (2018). https://github.com/CodeCrafter47/merge-insertion

  13. Stober, F., Weiß, A.: On the Average Case of MergeInsertion. arXiv e-prints. abs/1905.09656 (2019)

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Armin Weiß .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2019 Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Stober, F., Weiß, A. (2019). On the Average Case of MergeInsertion. In: Colbourn, C., Grossi, R., Pisanti, N. (eds) Combinatorial Algorithms. IWOCA 2019. Lecture Notes in Computer Science(), vol 11638. Springer, Cham. https://doi.org/10.1007/978-3-030-25005-8_34

Download citation

  • DOI: https://doi.org/10.1007/978-3-030-25005-8_34

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-030-25004-1

  • Online ISBN: 978-3-030-25005-8

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics