### Program to Radix sort in java

Contents of page >
• Steps to sort array using radix sort in java >
• Example to sort array using radix sort by using the above steps in java >
• Full Program/SourceCode/Example to sort array using radix sort in java>
• Complexity of radix sort in java >

Steps to sort array using radix sort in java >
First all the array elements are divided into group of 10 (i.e. in buckets), according to the value of their 1’s
Digit. (Please note number of groups may be less  than 10 - see below example)

Then all of these 10 groups are reassembled. At this stage elements whose 1’s digit is ending with 0 go first, then elements whose 1’s digit is ending with 1 and so on till elements whose 1’s digit is ending with 9.

Then array elements are divided into group of 10, according to the value of their 10’s
Digit.

Then all of these 10 groups are reassembled. At this stage elements whose 10’s digit is ending with 0 go first, then elements whose 10’s digit is ending with 1 and so on till elements whose 10’s digit is ending with 9.

Example to sort array using radix sort by using the above steps in java >
821 201 112 634 891 109 100 405 503 892 > Array is unsorted
(100) (821, 201, 891) (112, 892) (503) (634) (405) (109) > Array is sorted on 1s digit
(100, 201, 503, 405, 109) (112) (821) (634) (891, 892) > Array is sorted on 10s digit
(100, 109, 112) (201) (405) (503) (634) (821, 891, 892) > Array is sorted on 100s digit
100 109 112 201 405 503 634 821 891 892) > Array is sorted

Full Program/SourceCode/Example to sort array using radix sort in java>

Complexity of radix sort in java >

Radix Sort complexity worst case =  O(nk)
Radix Sort average case = O(nk)
Radix Sort best case = O(nk)

Summary >
So in this data structure tutorial we learned

Having any doubt? or you you liked the tutorial! Please comment in below section.