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.
- Create buckets (for decimal it would be 10, from 0 to 9 digits)
- Iterate all number of array one by one
- Find digit at once place
- Put number in bucket based on digit
- Put number back to array from bucket
- Iterate same for all digits of all numbers
Complexity : O(kn) for n keys which are integers of word size k.
Latest Source Code:
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]