Re:Algorithmic complexity attacks and libc qsort()
by j2kun on Wednesday June 11, 2014 @11:04AM
(#7878346)
I've always liked mergesort for this reason. It's easier to understand and there's no wondering about complexity.
[ Parent
| on HN ]
Re:Algorithmic complexity attacks and libc qsort()
by astrada on Wednesday June 11, 2014 @11:20AM
(#7878447)
Well, sometimes you have space constraints. The O(n) extra-space required by mergesort isn't always available. But if you don't have space constraints, mergesort is a very good choice because you can easily write a highly scalable parallel version of the algorithm.
Re:Algorithmic complexity attacks and libc qsort()
by boomzilla on Wednesday June 11, 2014 @02:02PM
(#7879419)
You can implement merge sort in place too:
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.22....
Looks like the algo is more complicated, but surely implementable. In most modern architectures, the key for performance is how one exploits the caching behavior. Quicksort is very cache friendly, as well as the common implementation of merge sort. Not so for heapsort.
Re:Algorithmic complexity attacks and libc qsort()
by phkahler on Wednesday June 11, 2014 @12:54PM
(#7879007)
"The O(n) extra-space required by mergesort isn't always available."
Heapsort
Re:Algorithmic complexity attacks and libc qsort()
by lsb on Wednesday June 11, 2014 @12:34PM
(#7878899)
No, but mergesort can easily fall back to dumping its sorted contents to disk, for later merging; this disk-based merge sort was invented by van Neumann in the 1940s, and is how the unix utility sort works (dozen-way merge of sorted shards of a file).