Is Quick Sort the Most Efficient Sorting Algorithm Available?

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
2 replies · 3K views
viv0411
Messages
1
Reaction score
0
Is quick sort the most efficient algorithm or there is a possibility of a perfect sorting algorithm to be discovered?
 
on Phys.org
quick sort isn't even the most efficient current algorithm, it's worst case is O(n^2) but is quick and easy to code and the inner loop fits in the CPU cache so is fast enough normally.

merge and heap sorts are both O(n ln n) worst case but in practice are slower.
 
Merge sort can be faster than quicksort, especially when using pointers to data where the average compare size (before a mismatch) is greater than a pointer size. For true random data, I used a hybrid radix (bucket) / merge sort, which was the fastest, but required a large amount of memory.

Previous threads on sorting. I included some test results in post #16 of the thread in the first link:

https://www.physicsforums.com/showthread.php?t=218369

https://www.physicsforums.com/showthread.php?t=181589