Docsity

Radix Sort Algorithm: A Step-by-Step Guide, Slides of Data Structures and Algorithms

Partial preview of the text

Download Radix Sort Algorithm: A Step-by-Step Guide and more Slides Data Structures and Algorithms in PDF only on Docsity!

By NIDA ZIA

RADIX SORT

RADIX SORT

Radix sort is generalization of bucket sort. It uses several passes of bucket sort Perform the bucket sorts by “least significant digits” _ First sort by digit in units place _ Second sort by digit in tens place _ Third sort by digit in hundreds place

RIGHT-MOST

Digit is 4

RIGHT-MOST Digit is 8 so we move it on 8 th place RIGHT-MOST Digit is 008

RIGHT-MOST Digit is 6 RIGHT-MOST Digit is 6 (216) so we move it on 6 th place

RIGHT-MOST Digit is 7 RIGHT-MOST Digit is 7 (27) so we move it on 7 th place

RIGHT-MOST Digit is 9 RIGHT-MOST Digit is 9 (729 )so we move it on 9 th place

RIGHT-MOST Digit is 1 RIGHT-MOST Digit is 1 so we move it on 1 st place

RIGHT-MOST Digit is 3 RIGHT-MOST Digit is 3 (343) so we move it on 3 rd place

PASS ONE COMPLETED

NOW MOVE TO SECOND

PASS

LET’S SORT THE ABOVE

ARRAY USING RADIX SORT.

  • Pass
  • Pass

Second RIGHT-MOST Digit is 0 Second RIGHT-MOST Digit is 0 (01) so we move it on 0 th place

Second RIGHT-MOST Digit is 1 Second RIGHT-MOST Digit is 1 (512) so we move it on 1 st place