Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Quicksort ain't shit

Name: Anonymous 2016-08-15 17:16

The fact that it's a commonly taught sorting algorithm is just an accident of history and imperative languages' being popular. It's actually quite a lot more complex than merge sort or heap sort and it's much harder to analyze. (Proving that merge sort runs in O(n log n) is relatively easy; proving that quicksort runs in O(n log n) in expectation is quite hard.)

Name: Anonymous 2016-08-15 17:28

quicksort [] = []
quicksort (p:xs) = quicksort less ++ [ p ] ++ quicksort more
where
less = [ x | x <- xs, x < p ]
more = [ x | x <- xs, x >= p ]

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List