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

This pisses me off so bad:

Quicksort does NOT have "the best big-O". It's big-O time complexity is O(n^2). Big-O refers to the worst case time complexity. Quicksort will on average take (n log n) time complexity, but that's not its big-O, that's its big-Theta. Some try to skirt this by saying "if you randomize the order of the data first, it will be sorted in big-O of n log n" but again, that's the average time complexity, not the pathological case.

A lot of CS books teach this wrong. Please stop being wrong: O(Quicksort) is O(n^2)




Big-Theta is not an average case, it is a special form of Big-O and Big-Omega wherein the worst case is also the best case from a complexity perspective.

This is sometimes true in sorting since comparison based sorting cannot be improved beyond n*log(n) except in specific cases for specific domains.

You are absolutely on the money about worst case being O(n^2) though for quicksort.


I stand corrected. Is there a notation for "average" complexity?


Not that I'm aware of! As you've seen, I see Big-O abused into shorthand for "on the order of" to the effect of "average case is O(nlog(n))"




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: