Hacker News new | past | comments | ask | show | jobs | submit login

Only naive implementations of quicksort take O(n^2) time. Most good implementations will switch to another sort (generally heapsort) after detecting adversarial conditions.



In which case they cease to be quicksort, and are instead called "introsort": http://en.wikipedia.org/wiki/Introsort


My point was that we should give good hackers the benefit of the doubt when they say quicksort, as they are likely to actually be talking about introsort. GNU C uses introsort to implement qsort, and if I were to implement quicksort for an important job, I certainly wouldn't overlook the fact that it can run to O(N^2).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: