News for hackers. Stuff that matters.
Re:Bubblesort, rocksort, and cocktail-shaker sort by avocad on Wednesday December 16, 2020 @04:39AM (#25440641)
That was a great article! The last paragraph, however:

"By the way, Knuth is interested in these algorithms mainly for the interesting mathematical problems (...) not because they’re in any way efficient algorithms! "

Made me wonder, these kind of algorithms, where there is a lot of comparing and swapping of adjacent records might be more efficient on a tape-based architecture. Or an architecture with a lot of prefetch caching.

Re:Bubblesort, rocksort, and cocktail-shaker sort by vanderZwan on Wednesday December 16, 2020 @08:14AM (#25442095)
Insertion sort is known to be the fastest option for small ranges, which is why it often is the sorting option hybrid sorts switch to for that case (like when the partitions in quicksort or merge sort are small enough).

AFAIK, this is mainly because even though it is expected O(n²), it has a really tiny overhead because insertion sort is incredibly simple, so for small enough n it wins. However, being very cache-friendly is also part of it (it's a linear search over the array).

IIRC some people found similar results for bubble sort.

Re:Bubblesort, rocksort, and cocktail-shaker sort by steerablesafe on Wednesday December 16, 2020 @10:06AM (#25443381)
It's both cache-friendly and its branches are easy to predict.