Which is the best sorting algorithm and why? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Which is the best sorting algorithm and why?

Like which algorithm takes the least time and space complexity and ??

24th Jul 2017, 5:41 PM
Shubham Kr Singh
Shubham Kr Singh - avatar
2 Answers
+ 3
It depends on the situation. @Martine Quick sort is likely best performing when the elements are randomly sorted before hand. Quick sort is not that fast when the list is already almost sorted. Although, it does have very good average performance. @Shubham So the answer is, under what situation? Here's a great website comparing lots of algorithms under certain conditions. (Animated) https://www.toptal.com/developers/sorting-algorithms
24th Jul 2017, 9:46 PM
Rrestoring faith
Rrestoring faith - avatar
0
Quicksort is the best. Its complexity is n*log(n).
24th Jul 2017, 7:08 PM
Martin Bulíř