+ 1

Sorting algorithm

Which is the best sorting algorithm??

2nd Nov 2018, 3:14 PM
1704086_ibnul
1704086_ibnul - avatar
3 Antworten
+ 4
n log(n) sorting algortihms like quicksort or mergesort are the "best" in general. But in the end it heavily depends on your data and architecture (small vs. big data, serial vs. parallel). For small amount of data insertion sort is already very good. So there is actually no "best" algorithm.
2nd Nov 2018, 3:22 PM
Matthias
Matthias - avatar
+ 4
Theoretically, an algorithm with least time and space is the best, but the same algorithm would have different complexity with different data, that's why we can only say its complexity in best, average or worst case
2nd Nov 2018, 3:40 PM
Flandre Scarlet
Flandre Scarlet - avatar
0
"Everyday data" is usually not completely random and that's why python for example uses Timsort, which takes advantage of already sorted parts of your list. It does pretty well in practice even though quicksort probably has better theoretical performance.
2nd Nov 2018, 7:12 PM
Schindlabua
Schindlabua - avatar