Exercise generation and helpful materials for the Introduction to Algorithms and Data Structures 📚
RadixSort is a non-comparative, stable sorting algorithm. Comparisons are substituted by placing elements into so-called buckets based on their radix (digits).
Due to other algorithms having to execute pair-wise key comparisons, they can never
exceed a best case of O(n log n)
. Under special circumstances (see below), RadixSort can exceed this boundary.
4
if
the highest number is 1111
LSD (least significant digit) first focuses on the last digit in the element.
e.g. in 1234
this would be 4
MSD (most significant digit) is unsurprisingly the opposite of LSD, where the first digit is considered first, hence 1 in the above example.
LSD radix sort is more common than MSD in most conventional implementations.
RadixSort is a special case when it comes to runtimes, since the time is
dependent on the number of digits k
that have to be considered.
Best | Average | Worst | Stability |
---|---|---|---|
Ω(nk) |
Θ(nk) |
O(nk) |
yes |