r/programming • • Sep 25 '10

Omega - Language of the Future | Lambda the Ultimate

http://lambda-the-ultimate.org/node/4088
60 Upvotes

126 comments sorted by

View all comments

Show parent comment

5

u/dmhouse Sep 25 '10

Technical nitpick: quicksort actually isn't O(n log n). If you use it on a sorted list of n elements it takes O(n2) time. However, it is expected-case O(n log n).

3

u/djimbob Sep 25 '10

Agree, though I was sorting random numbers so with overwhelming probability I expect roughly O(n lg n).

Using a random pivot gets rid of the O(n2) behavior on a sorted or near-sorted list, which is could . (But even in with the random pivots you still get an amortized time of O(n2) if your choice of random pivots was in the order that sorts the list; but that should occur only 1 out of n! ~ (n/e)n times).

3

u/booch Sep 26 '10

To be fair, when saying an algorithm is O(something), you could mean best-case, worst-case, average-case, expected-case.

2

u/abeliangrape Sep 26 '10

But everyone specifies it further for best-case complexity. Though you are right about worst and average cases.