2

Heap sort or Quicksort?

 7 months ago
source link: https://codeforces.com/blog/entry/125352
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Hello, I have a question about heap sort and quicksort. Which one is faster and which one should i use?

4 hours ago, # |

Quicksort is faster than heapsort. Quicksort is usually about 2–3 times faster than heapsort. This is because quicksort's inner loop can be implemented efficiently on most architectures. Use quicksort if you prioritize speed and memory usage is not a concern, have a medium-sized dataset that fits in memory. Use heap sort if need a guarantee of worst-case performance (O(nlogn)), doing external sorting with large datasets.


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK