Radix Sort Final
Radix Sort Final
(W-8)
Q2.Describe the principal of radix sort
with one example.
Q3.Describe radix sort algorithm.
(W-15)
• Radix sort is the generalization of bucket sort.
• To sort decimal numbers, where the radix or base is 10, we
need 10 buckets.
• These buckets are numbered 0,1,2,3,4,5,6,7,8,9.
• Sorting is done in passes.
• Number of passes required to sort is equal to number of digits
in the largest number in the list.
Range Passes
0 to 99 2 passes
0 to 999 3 passes
0 to 9999 4 passes
• In the first pass, numbers are sorted on least significant digit.
Numbers with the same least significant digit are stored in the
same bucket.
• In the 2nd pass, numbers are stored on the second least
significant digit.
• At the end of every pass, numbers in buckets are merged to
produce a common list.
• Number of passes depends on the range of numbers being
sorted.
• Radix sort is a sorting technique that sorts the elements by first
grouping the individual digits of the same place value.
• Radix sort works by sorting each digit from least significant
digit to most significant digit.
• So in base 10 (the decimal system), radix sort would sort by the
digits in the 1's place, then the 10’s place, and so on. To do this,
radix sort uses counting sort as a subroutine to sort the digits in
each place value.
• This means that for a three-digit number in base 10, counting
sort will be called to sort the 1's place, then it will be called to
sort the 10's place, and finally, it will be called to sort the 100's
place, resulting in a completely sorted list.
10 5 99 105 55 100 135 141 137 200 199
135
200 55
10 141 5 137 99
0 1 2 3 4 5 6 7 8 9
105
55 135
10 105
5 100 200
0 1 2 3 4 5 6 7 8 9
3 84 25 67
10 103 304 15 36 7 28 49
0 1 2 3 4 5 6 7 8 9
7
304
003 15 28
103 10 25 36 49 67 84
0 1 2 3 4 5 6 7 8 9
84
67
49
36
28
25
15
10
7
3 103 304
0 1 2 3 4 5 6 7 8 9
614
5381 14 47 348
0 1 2 3 4 5 6 7 8 9
614 348
14 47 5381
0 1 2 3 4 5 6 7 8 9
47 5381
14 348 614
0 1 2 3 4 5 6 7 8 9
614
348
47
14 5381
0 1 2 3 4 5 6 7 8 9