Radix Sort

Radix Sort

Radix Sort is a non-comparative integer sorting algorithm that sorts data with integer keys by grouping keys by the individual digits which share the same significant position and value.

Algorithm:

  1. Create buckets (for decimal it would be 10, from 0 to 9 digits)
  2. Iterate all number of array one by one
    1. Find digit at once place
    2. Put number in bucket based on digit
  3. Put number back to array from bucket
  4. Iterate same for all digits of all numbers

Complexity : O(kn) for n keys which are integers of word size k.

Latest Source Code:
Github: RadixSort.java


Output:

Before sorting: [2, 14, 1211, 32, 422, 54, 2, 11, 23, 1661, 212]
After sorting: [2, 2, 11, 14, 23, 32, 54, 212, 422, 1211, 1661]
Author: Hrishikesh Mishra