I just wrote a quicksort, it is extremely easy to avoid O(n^2) perf on presorted, or reverse sorted arrays.
Only the most naive implementations will behave that way.
Also, memory usage should be controlled by using a stack to eliminate recursion overhead and modifying the algorithm to be an in place sort instead of using 2 separate arrays for the high and low values.
You are correct that the basic recursive quicksort algorithm will behave badly in this case though.
@spechtbert No really, quicksort uses a lot of memory when fed a fully-sorted or mostly-sorted array. Look it up. quicksort has a O(n^2) if it's sorting a presorted array.
@Mank25 fuck off ive invented a sort quicker than quicksort but im gonna release it after my patent has been processed my new way to sort is gonna change the world wait and see
@blauhuden111
I just wrote a quicksort, it is extremely easy to avoid O(n^2) perf on presorted, or reverse sorted arrays.
Only the most naive implementations will behave that way.
Also, memory usage should be controlled by using a stack to eliminate recursion overhead and modifying the algorithm to be an in place sort instead of using 2 separate arrays for the high and low values.
You are correct that the basic recursive quicksort algorithm will behave badly in this case though.
CMark342 3 months ago
this animation is cool^^
ComedyNaruto 6 months ago
quicksort sucks if the data is already close to being sorted... and it uses loads of memory.
T0B0KKE 6 months ago
@T0B0KKE rofl.
spechtbert 3 months ago
@spechtbert It's the truth.
T0B0KKE 3 months ago
@T0B0KKE sure.
spechtbert 3 months ago
@spechtbert No really, quicksort uses a lot of memory when fed a fully-sorted or mostly-sorted array. Look it up. quicksort has a O(n^2) if it's sorting a presorted array.
blauhunden111 3 months ago
If you want interesting sorts, look into Smoothsort.
Magnetohydrodynamics 7 months ago
is the other sort tweeked selection sort ??? far more interesting than selection... still Quick is quick for the quicksort :P
putzmitt3l 1 year ago
@putzmitt3l It looks to me like its a kind of bubble sort, only it goes is two directions.
dented42 1 year ago
@dented42 Yes. Shakersort is bidirectional bubblesort.
thaimodz 1 year ago 9
Quicksort's quick, yeah yeah yeah!
Mank25 2 years ago 13
@Mank25 fuck off ive invented a sort quicker than quicksort but im gonna release it after my patent has been processed my new way to sort is gonna change the world wait and see
woo216 8 months ago
@Mank25 It's not slow,no no no!
BushHatesMe 1 month ago
@BushHatesMe I love replying to 2 year old comments too!
someonerules 1 month ago
nice;)
skkissjanos 3 years ago