Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When should we use Radix sort?

It seems Radix sort has a very good average case performance, i.e. O(kN): http://en.wikipedia.org/wiki/Radix_sort

Yet it seems like most people are still using Quick Sort - why is this?

like image 415
Howard Avatar asked Nov 10 '10 16:11

Howard


2 Answers

Radix sort is harder to generalize than most other sorting algorithms. It requires fixed size keys, and some standard way of breaking the keys into pieces. Thus it never finds its way into libraries.

like image 191
Mark Ransom Avatar answered Sep 23 '22 14:09

Mark Ransom


The other answers here fail to give examples of when radix sort is actually used.

An example is when creating a "suffix array" using the skew DC3 algorithm (Kärkkäinen-Sanders-Burkhardt). The algorithm is only linear-time if the sorting algorithm is linear-time, and radix sort is necessary and useful here because the keys are short by construction (3-tuples of integers).

like image 29
user541686 Avatar answered Sep 25 '22 14:09

user541686