Re:Proving that Android’s, Java’s and Python’s sorting algor...
by maxlybbert on Tuesday February 24, 2015 @10:55AM
(#9101305)
It doesn't have to have poor worst-case behavior: https://www.cs.princeton.edu/~rs/talks/QuicksortIsOptimal.pd... (from the author of the Algorithms textbook used at my college).
[ Parent
| on HN ]
Re:Proving that Android’s, Java’s and Python’s sorting algor...
by ufo on Tuesday February 24, 2015 @01:20PM
(#9102445)
Correct me if I'm wrong but I got the impression that prof Sedgewick's slides were about quicksort behaviour when the input has many equal keys. That would still result in quadratic runtime against maliciously crafted input.
Re:Proving that Android’s, Java’s and Python’s sorting algor...
by maxlybbert on Tuesday February 24, 2015 @03:25PM
(#9103250)
I may have oversold Sedgewick's claim: he doesn't actually say that a properly implemented quicksort will never go quadradic; only that "The average number of compares per element ... is always within a constant factor of the entropy" and "No comparison-based algorithm can do better" (page 16).
I've never looked into whether a Sedgewick-approved Quicksort can avoid worst case behavior against antiquicksort ( http://www.cs.dartmouth.edu/~doug/aqsort.c , http://www.cs.dartmouth.edu/~doug/mdmspe.pdf ).