Papers
Topics
Authors
Recent
Gemini 2.5 Flash
Gemini 2.5 Flash
167 tokens/sec
GPT-4o
7 tokens/sec
Gemini 2.5 Pro Pro
42 tokens/sec
o3 Pro
4 tokens/sec
GPT-4.1 Pro
38 tokens/sec
DeepSeek R1 via Azure Pro
28 tokens/sec
2000 character limit reached

Simple Symmetric Sustainable Sorting -- the greeNsort article (2402.01816v1)

Published 2 Feb 2024 in cs.DS, cs.CY, cs.DC, and cs.PF

Abstract: We explored an uncharted part of the solution space for sorting algorithms: the role of symmetry in divide&conquer algorithms. We found/designed novel simple binary Quicksort and Mergesort algorithms operating in contiguous space which achieve improved trade-offs between worst-case CPU-efficiency, best-case adaptivity and RAM-requirements. The 'greeNsort' algorithms need less hardware (RAM) and/or less energy (CPU) compared to the prior art. The new algorithms fit a theoretical framework: 'Footprint' KPIs allow to compare algorithms with different RAM-requirements, a new 'definition' of sorting API-targets simplifies construction of stable algorithms with mirrored scan directions, and our ordinal machine model encourages robust algorithms that minimize access 'distance'. Unlike earlier 'Quicksorts', our 'Zacksort', 'Zucksort' and 'Ducksort' algorithms optimally marry CPU-efficiency and tie-adaptivity. Unlike earlier 'Mergesorts' which required 100% distant buffer, our 'Frogsort' and 'Geckosort' algorithms achieve similar CPU-efficiency with 50% or less local buffer. Unlike natural Mergesorts such as 'Timsort' which are optimized for the best case of full-presorting, our 'Octosort' and 'Squidsort' algorithms achieve excellent bi-adaptivity to presorted best-cases without sacrificing worst-case efficiency in real sorting tasks. Our 'Walksort' and 'Jumpsort' have lower Footprint than the impressive low-memory 'Grailsort' and 'Sqrtsort' of Astrelin. Given the current climate-emergency, this is a call to action for all maintainers of sorting libraries, all software-engineers using custom sorting code, all professors teaching algorithms, all IT professionals designing programming languages, compilers and CPUs: check for better algorithms and consider symmetric code-mirroring.

Definition Search Book Streamline Icon: https://streamlinehq.com
References (30)
  1. Astrelin, A. (2013). Grailsort.
  2. In-Place Parallel Super Scalar Samplesort (IPSSSSo). In Pruhs, K. and Sohler, C., editors, 25th Annual European Symposium on Algorithms (ESA 2017), volume 87 of Leibniz International Proceedings in Informatics (LIPIcs), pages 9:1–9:14, Dagstuhl, Germany. Schloss Dagstuhl–Leibniz-Zentrum fuer Informatik.
  3. Engineering in-place (shared-memory) sorting algorithms. ACM Trans. Parallel Comput., 9(1).
  4. Insertion sort is o(n log n). Theory of Computing Systems, 39(3):391–397.
  5. Engineering a sort function. Softw. Pract. Exper., 23(11):1249–1265.
  6. Dongarra, J. J. (2022). The evolution of mathematical software. Commun. ACM, 65(12):66–72.
  7. Blockquicksort: How branch mispredictions don’t affect quicksort. CoRR, abs/1604.06697.
  8. Hoare, C. A. R. (1961a). Algorithm 63: Partition. Commun. ACM, 4(7):321.
  9. Hoare, C. A. R. (1961b). Algorithm 64: Quicksort. Commun. ACM, 4(7):321.
  10. Hoare, C. A. R. (1961c). Algorithm 65: Find. Commun. ACM, 4(7):321–322.
  11. Hoare, C. A. R. (1962). Quicksort. The Computer Journal, 5(1):10–16.
  12. Fast stable merging and sorting in constant extra space. j-COMP-J, 35(6):643–650.
  13. A meticulous analysis of mergesort programs. In Bongiovanni, G., Bovet, D. P., and Di Battista, G., editors, Algorithms and Complexity, pages 217–228, Berlin, Heidelberg. Springer Berlin Heidelberg.
  14. Knuth, D. (1973). The Art Of Computer Programming, vol. 3: Sorting And Searching. Addison-Wesley.
  15. Knuth, D. E. (1998). The art of computer programming, volume 3: (2nd ed.) sorting and searching. Addison Wesley Longman Publishing Co., Inc., Redwood City, CA, USA.
  16. Mehlhorn, K. (1977). Data Structures and Algorithms, volume 1: Sorting and Searching. Teubner, Stuttgart, Leipzig.
  17. Nearly-Optimal Mergesorts: Fast, Practical Sorting Methods That Optimally Adapt to Existing Runs. In Azar, Y., Bast, H., and Herman, G., editors, 26th Annual European Symposium on Algorithms (ESA 2018), volume 112 of Leibniz International Proceedings in Informatics (LIPIcs), pages 63:1–63:16, Dagstuhl, Germany. Schloss Dagstuhl–Leibniz-Zentrum fuer Informatik.
  18. Peters, O. (2014). [patch] bug 20837 - libc++ std::sort has o(n²) worst case, standard mandates o(n log(n)). llvm bug report.
  19. Peters, O. (2015). pdqsort. github code.
  20. Peters, O. R. L. (2021a). Agreed on pdqsort … Hacker News.
  21. Peters, O. R. L. (2021b). Pattern-defeating quicksort. CoRR, abs/2106.05123.
  22. Peters, T. (2002). I wrote a sort for python. ’Sorting’ mail to the Python-Dev list.
  23. Sedgewick, R. (1977). The analysis of quicksort programs. Acta Inf., 7:327–355.
  24. Sedgewick, R. (1990). Algorithms in C. Addison-Wesley Professional, 2 edition.
  25. Singleton, R. C. (1969). Algorithm 347: An efficient algorithm for sorting with minimal storage [m1]. Commun. ACM, 12(3):185–186.
  26. Skarupke, M. (2016). I wrote a faster sorting algorithm.
  27. The UK Parliamentary Office of Science and Technology (2022). Energy consumption of ict.
  28. von Leitner, F. (2007). diet libc - a libc optimized for small size.
  29. Wegner, L. M. (1985). Quicksort for equal keys. IEEE Trans. Computers, 34(4):362–367.
  30. Yaroslavskiy, V. (2009). Dual-pivot quicksort.

Summary

We haven't generated a summary for this paper yet.