Learn How Radix Sort Method Works

 Step 1: DIV=1 NUM=0 Step 2: MAX = a [0] Step 3: Repeat step4 for I=1 to N Step 4: If a [I] > MAX then MAX = a [I] Step 5: Repeat Step 6 while MAX > 0 Step 6: NUM = NUM + 1 MAX = MAX/10 Step 7: Repeat up to Step 16 for PASS=1 to NUM Step 8: Repeat Step9 for K=0 to N Step 9: Pock [K] = 0 Step 10: Repeat step11 for I=1 to N Step 11: DIGIT = (a [I]/div) % 10 Pocket [DIGIT] [Pock [DIGIT] ++] = a [I] Step 12: I=0 Step 13: Repeat up to Step15 for K=0 to 10 Step 14: Repeat Step15 for J=0 to Pock [K] Step 15: a [I] = Pocket [K] [J] I=I+1 Step 16: DIV=DIV*10

#include<stdio.h>
#include<conio.h>
#define N 10
void main()
{
int a[N],i;
clrscr();
printf("Enter Elements in array\n");
for(i=0;i<N;i++)
{
printf("Enter Value of A[%d]:",i);
scanf("%d",&a[i]);
}
printf("Sorted List\n");
for(i=0;i<N;i++)
{
printf("A[%d]=%d\n",i,a[i]);
}
getch();
}
{
int pocket[10][10],pock[10],i,j,k,digit,max,num=0,pass,div=1;
max=a[0];
for(i=0;i<N;i++)
{
if(a[i]>max)
max=a[i];
}
while(max>0)
{
num++;
max=max/10;
}
for(pass=0;pass<num;pass++)
{
for(k=0;k<10;k++)
{
pock[k]=0;
}
for(i=0;i<N;i++)
{
digit=(a[i]/div)%10;
pocket[digit][pock[digit]++]=a[i];
}
i=0;
for(k=0;k<10;k++)
{
for(j=0;j<pock[k];j++)
{
a[i++]=pocket[k][j];
}
}
div*=10;
}
}