Today was a good day

Ivan Kazmenko via Digitalmars-d digitalmars-d at puremagic.com
Fri Jan 15 12:49:05 PST 2016


On Wednesday, 13 January 2016 at 03:38:45 UTC, Andrei 
Alexandrescu wrote:
> I tried a static rng but found out that pure functions call 
> sort(). Overall I'm not that worried about attacks on sort().

So, sort() is still Introsort (O(n log n) worst case), but topN() 
can show quadratic performance?  Can a similar approach - fall 
back to just sorting in O(n log n) if we recurse too deep - be 
applied to topN() so that it is linear for sane inputs but O(n 
log n) in the worst case?



More information about the Digitalmars-d mailing list