

Radix Sort Revisited - silentbicycle
http://codercorner.com/RadixSortRevisited.htm

======
cperciva
_[Radix sort] breaks the theoretical lower bound of the O(N_ logN) complexity,
which only applies for comparison-based sorts. Radix is O(k _N), with k = 4
most of the time_

Sigh. In fact, radix sort is O(k*N) with k = log N. There's nothing magical
about it.

More precisely, radix sort is O(N log U) where U is the number of distinct
values the inputs can take (e.g., U = 2^32 for 32-bit integers) while
comparison sorts are O(N log R) where R is the number of distinct input values
(e.g., R = N if the values to be sorted are distinct). Radix sorts often win
due to being easy to implement efficiently, but they have the same or worse
asymptotic behaviour.

~~~
ssp
If you are going to say that there really are log _n_ bits in a word, then you
also need to account for the time it takes to actually do a comparison, which
would be Omega(log _n_ ) in the worst case because you can't describe _n_
values with less than log _n_ bits -- making comparison sort Omega ( _n_ log^2
_n_ )

~~~
cperciva
You don't need to compare all the bits in a word -- you just need to find the
first place where two values differ.

~~~
SamReidHughes
The length of the common prefix generally grows linearly from 1 to O(log(n))
on randomly distributed values (and worse on less-randomly distributed values)
-- if you follow a given value, it starts off being compared against another
random value, then against a value with probably one bit in common, then
against a value with probably two bits in common, and so on, until O(log(n))
comparisons have been done.

