Shakersort vs. Quicksort
Top Comments
All Comments (16)
-
@BushHatesMe I love replying to 2 year old comments too!
-
@Mank25 It's not slow,no no no!
-
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.
-
@T0B0KKE sure.
-
@spechtbert It's the truth.
-
@T0B0KKE rofl.
-
this animation is cool^^
-
quicksort sucks if the data is already close to being sorted... and it uses loads of memory.
-
If you want interesting sorts, look into Smoothsort.
Quicksort's quick, yeah yeah yeah!
Mank25 2 years ago 13
@dented42 Yes. Shakersort is bidirectional bubblesort.
thaimodz 1 year ago 9