+ 1
Sorting algorithm
Which is the best sorting algorithm??
3 Respuestas
+ 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.
+ 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
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.