0% found this document useful (0 votes)
65 views

Radix Sort

Radix sort is a non-comparative sorting algorithm that sorts numeric data by grouping keys by the individual digits that share the same significant position and value. It works by sorting each digit from least significant to most significant. Radix sort requires minimal data movement and no comparisons, making it one of the fastest algorithms for sorting numbers. While it has advantages for numeric data, radix sort has limitations for other data types and requires more space than some other algorithms like quicksort.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views

Radix Sort

Radix sort is a non-comparative sorting algorithm that sorts numeric data by grouping keys by the individual digits that share the same significant position and value. It works by sorting each digit from least significant to most significant. Radix sort requires minimal data movement and no comparisons, making it one of the fastest algorithms for sorting numbers. While it has advantages for numeric data, radix sort has limitations for other data types and requires more space than some other algorithms like quicksort.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 49

Radix Sort

Presented To- Presented By-


Md. Bayazid Nazmul Hassan
Rahman
Limon
Lecturer of
NDUB ID: 183120002
Batch: CSE-09
What is Radix Sort?

1. We have seen many algorithm but this one is different , it is not


based on
general algorithm strategy , but on a totally different method.
2. It is interesting because it requires the absolute minimum
amount of space and the minimum amount of data movement,
and most amazing of all, it does no comparisons.
3.  In Computer Science Radix Sort is a non – comparative integer
sorting algorithm that sort data with integer keys by grouping keys by
the individual digits which share same significant position and value
WHY IT IS CALLED ‘ RADIX ’ ?
Radix Means : the base of a system of numeration.

Examples:
The decimal number system that we use every day has
10 digits {0,1,2,3,4,5,6,7,8,9} and so the radix is 10.
How Radix Sort Works?
1. Radix sort works by sorting each digit from least
significant digit to most significant digit.
2. 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.
3.To do this, radix sort uses counting sort as a subroutine
to sort the digits in each place value.
What are the advantages of Radix
Sort?

1. Radix sort algorithm is well known for its


fastest sorting algorithm for numbers and even for strings
of letters. 
2. Radix sort algorithm is the most efficient algorithm
for elements which are arranged in descending order in an
array.
What are the limitations of Radix Sort?

1. Since Radix Sort depends on digits or letters, Radix Sort is much less flexible
than other
sorts. Hence , for every different type of data it needs to be rewritten.

2. The constant for Radix sort is greater compared to other sorting algorithms.

3. It takes more space compared to Quicksort which is in place sorting.

4. Radix Sort can be slower than some other algorithms such as Quick Sort and
Merge Sort.
Classification of Radix Sort :

1. Least Significant Digit (LSD) radix sorts.


2. Most Significant Digit (MSD) radix sorts
LEAST SIGNIFICANT DIGIT (LSD) RADIX
SORTS

How many times we will sort the number ?


OR
How many passes will required ?
LEAST SIGNIFICANT DIGIT (LSD) RADIX
SORTS

Examples : 4310 , 357 ,


251 , 78
LEAST SIGNIFICANT DIGIT (LSD) RADIX
SORTS

Examples : 4310 , 357 , 251 , 78

431
0
So 4 passes will require 
EXAMPLE (LSD)
Input List:

126 328 636 341 416 131 328


EXAMPLE (LSD)
Sort on lower digit / Pass 1 :

126 328 636 341 416 131 328


EXAMPLE (LSD)
Sort on lower digit / Pass 1 :

126 328 636 341 416 131 328

0 1 2 3 4 5 6 7 8 9
EXAMPLE (LSD)
Sort on lower digit / Pass 1 :

126 328 636 341 416 131 328

0 1 2 3 4 5 6 7 8 9
126
EXAMPLE (LSD)
Sort on lower digit / Pass 1 :

126 328 636 341 416 131 328

0 1 2 3 4 5 6 7 8 9
126 328
EXAMPLE (LSD)
Sort on lower digit / Pass 1 :
126 328 636 341 416 131 328

0 1 2 3 4 5 6 7 8
9
126 328
636
EXAMPLE (LSD)
Sort on lower digit / Pass 1 :
126 328 636 341 416 131 328

0 1 2 3 4 5 6 7 8
9
341 126 328
636
EXAMPLE (LSD)
Sort on lower digit / Pass 1 :
126 328 636 341 416 131 328

0 1 2 3 4 5 6 7 8
9
341 126 328
636
416
EXAMPLE (LSD)
Sort on lower digit / Pass 1 :
126 328 636 341 416 131 328

0 1 2 3 4 5 6 7 8
9
341 126 328
131 636
416
EXAMPLE (LSD)
Sort on lower digit / Pass 1 :
126 328 636 341 416 131 328

0 1 2 3 4 5 6 7 8
9
341 126 328
131 636 328
416
EXAMPLE (LSD)
After Sorting :

341 131 126 636 416 328 328


EXAMPLE (LSD)
Sort on next higher digit/Pass 2 :

341 131 126 636 416 328 328


EXAMPLE (LSD)
Sort on next higher digit/Pass 2 :

341 131 126 636 416 328 328

0 1 2 3 4 5 6 7 8 9

341
EXAMPLE (LSD)
Sort on next higher digit/Pass 2 :

341 131 126 636 416 328 328

0 1 2 3 4 5 6 7 8 9

131 341
EXAMPLE (LSD)
Sort on next higher digit/Pass 2 :

341 131 126 636 416 328 328

0 1 2 3 4 5 6 7 8 9

126 131 341


EXAMPLE (LSD)
Sort on next higher digit/Pass 2 :

341 131 126 636 416 328 328

0 1 2 3 4 5 6 7 8 9

126 131 341


636
EXAMPLE (LSD)
Sort on next higher digit/Pass 2 :

341 131 126 636 416 328 328

0 1 2 3 4 5 6 7 8 9

416 126 131 341


636
EXAMPLE (LSD)
Sort on next higher digit/Pass 2 :
341 131 126 636 416 328 328

0 1 2 3 4 5 6 7 8
9
416 126 131 341
328 636
EXAMPLE (LSD)
Sort on next higher digit/Pass 2 :
341 131 126 636 416 328 328

0 1 2 3 4 5 6 7 8
9
416 126 131 341
328 636
328
EXAMPLE (LSD)

After Sorting:

416 126 328 328 131 636 341


EXAMPLE (LSD)

Sort on next higher digit/Pass 3 :

416 126 328 328 131 636 341


EXAMPLE (LSD)
Sort on next higher digit / Pass 3 :

416 126 328 328 131 636 341

0 1 2 3 4 5 6 7 8 9
416
EXAMPLE (LSD)
Sort on next higher digit / Pass 3 :

416 126 328 328 131 636 341

0 1 2 3 4 5 6 7 8 9
126 416
EXAMPLE (LSD)
Sort on next higher digit / Pass 3 :

416 126 328 328 131 636 341

0 1 2 3 4 5 6 7 8 9
126 328 416
EXAMPLE (LSD)
Sort on next higher digit / Pass 3 :

416 126 328 328 131 636 341

0 1 2 3 4 5 6 7 8 9
126 328 416
328
EXAMPLE (LSD)
Sort on next higher digit / Pass 3 :

416 126 328 328 131 636 341

0 1 2 3 4 5 6 7 8 9
126 328 416
131 328
EXAMPLE (LSD)
Sort on next higher digit / Pass 3 :

416 126 328 328 131 636 341

0 1 2 3 4 5 6 7 8 9
126 328 416 636
131 328
EXAMPLE (LSD)
Sort on next higher digit / Pass 3 :
416 126 328 328 131 636 341

0 1 2 3 4 5 6 7 8 9
126 328 416 636
131 328
341
EXAMPLE (LSD)

After Sorting :

126 131 328 328 341 416 636


Finally the sorted numbers:

126 131 328 328 341 416 636


Pseudocode of Radix Sort
Code Implementation in C :
Output of the Radix Sort:
Complexity Analysis of Radix
Sort:
• Best case time complexity: Ω(n k)
• Average case time complexity:θ(n k)
• Worst case time complexity: O(n k)
• Space complexity: O(n + k)
where n is the number of input data and k is the
maximum element in the input data.
Application of Radix Sort:

• Radix sort is mostly used in


parallel computing.
Sources
• 1. Google.
• 2. YouTube .
• 3.Wikipedia.
• 4.Quora.
Thank
You

You might also like