Friday, May 21, 2010

Which sorting algorithm is the fastest in C?

Quicksort is probably the most straight-forward sort to implement in C that will give you quick performance. Assuming that the array being sorted fits in memory, this will be very quick.





There's also a variation on bucket sort (count or radix sort) that may be a bit quicker than quicksort, though it depends on the nature of your data. This is because quicksort isn't necessarily the best on smaller lists so as the list size goes down, the algorithm applies other searches to the buckets that are more efficient on smaller data sets. That being said, this might be more complexity than it's worth depending on what you're trying to do.


No comments:

Post a Comment