0% found this document useful (0 votes)
71 views2 pages

Radix Sort

Radix Sort is a stable sorting algorithm that can sort keys represented as integers or strings in radix order. It works by processing the keys from least to most significant digit, grouping keys by their digit values at each position. This allows it to sort variable length keys in O(nk) time where n is the number of keys and k is the average key length.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
71 views2 pages

Radix Sort

Radix Sort is a stable sorting algorithm that can sort keys represented as integers or strings in radix order. It works by processing the keys from least to most significant digit, grouping keys by their digit values at each position. This allows it to sort variable length keys in O(nk) time where n is the number of keys and k is the average key length.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Radix Sort

A least significant digit (LSD) radix sort is a fast stablev sorting algorithm which can be used to sort keys in integer representation order. eys may be a string of characters! or numerical digits in a given "radix". #he processing of the keys begins at the least significant digit (i.e.! the rightmost digit)! and proceeds to the most significant digit (i.e.! the leftmost digit). #he se$uence in which digits are processed by a LSD radix sort is the opposite of the se$uence in which digits are processed by a most significant digit (%SD) radix sort. An LSD radix sort operates in &(nk) time! where n is the number of keys! and k is the average key length. #his kind of performance for variable'length keys can be achieved by grouping all of the keys that have the same length together and separately performing an LSD radix sort on each group of keys for each length! from shortest to longest! in order to avoid processing the whole list of keys on every sorting pass. Program: (include)stdio.h* (include)conio.h* (define +&,-# ./ int main() 0 int a1+&,-#23 int temp1+&,-#23 int i!max4/!x4.!si5e!54.3 clrscr()3 printf(67nter #he Si5e of the Array6)3 scanf(6:d6!;si5e)3 printf(67nter the Array 7lements<n6)3 for(i4/3i)si5e3i==) scanf(6:d6!;a1i2)3 printf(6#he >ou 7ntered is As ?<n6)3 for(i4/3i)si5e3i==) printf(6:Ad<t6!a1i2)3 for(i4/3i)si5e3i==) 0 if(a1i2*max) max4a1i23 E while(max85*/) 0 int buck1./240 / E3 for(i4/3i)si5e3i==) buck1((a1i28x)85):./2==3 for(i4.3i)G3i==) buck1i2=4buck1i'.23

889eading Array Si5e 889eading Array 7lements

88Display the ,nsorted@Array

88Binding the %ax Calue Dn Array

88Billing the Fucket with +ount 88Setting Hositions with Fucket

for(i4/3i)si5e3i'') 88Sorting Fased &n Hositions temp1''buck1((a1i28x)85):./224a1i23 printf(6<nHASS ?<t6)3 for(i4/3i)si5e3i==) 0 a1i24temp1i23 printf(6:Ad<t6!a1i2)3 E x84./3 5I4./3 E printf(6<n#he Sotred Array Ds As ?<n6)3 for(i4/3i)si5e3i==) printf(6:Ad<t6!a1i2)3 getch()3 return(/)3 E 88%aking &riginal Array with sort

88%oving to the next Hosition

88Display the Sorted@Array

You might also like