DEV Community

Discussion on: What is Quicksort

Collapse
 
tux0r profile image
tux0r • Edited

Despite the name, the quick sort algorithm has a worst-case complexity of O(n²). You might or might not want to try merge sort instead, depending on the size (and sorting state) of your list.

Collapse
 
lyfolos profile image
Muhammed H. Alkan

Add it!

Collapse
 
grayjack profile image
GrayJack

Or you could select a random element to be the pivot, that way you reduce a lot the chances of waving the worst case

Collapse
 
lyfolos profile image
Muhammed H. Alkan

Thanks for reminding me! I just forgot to add it.