Illustrate the operation of Radix sort on the following list
Illustrate the operation of Radix sort on the following list of integers:
36 9 0 25 1 49 64 16 81 4
Solution
################# RADIX SORT ##########################
Consider the input array
36 9 0 25 1 49 64 16 81 4
Sorting by least significant digit (1\'s place) gives:
[we keep 64 before 4, because 64 occurred before 4 in the original list, and similarly for 36 & 16 ]
0 1 81 64 4 25 36 16 9 49
Now sorting by 10\'s digit.
Note that numbers like 0, 1, 4, 9 have no tens digit,
thus, their tens digit will be 0.
considering 10\'s digit of unit numbers in the list to be 0
Sorting by next digit (10\'s place) gives:
0 1 4 9 16 25 36 49 64 81
Array is now sorted
