radix sort - c programwrite a program in c to


Radix sort - C program:

Write a program in c to define a radix sort.

void main()

{

 int array[100],n;

 int i;

 void radix(int *,int);

 printf ("How many nos\n");

 scanf("%d",&n);

 for(i= 0;i< n;i++)

 {

 printf("array[%d]=?",i+1);

 scanf("%d",&array[i]);

 }

                                    radix(array,n);

 for(i= 0;i< n;i++)

 printf("%d ",array[i]);

 getch();

 

 }

void radix(int *array,int n)

{

int a[2][100],ptr[2];

int i,b=1,j,k;

for(i=0;i<16;i++)

{

                ptr[0]=ptr[1]=0;

                for(j=0;j

                {

                                if((array[j]&(b<

                                                a[1][ptr[1]++]=array[j];

                                else                               /* bit wise operations*/

                                                a[0][ptr[0]++]=array[j];

                }

                for(j=0;j

                                array[j]=a[0][j];

                for(k=0;k

                                array[j+k]=a[1][k];

                }

}

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: radix sort - c programwrite a program in c to
Reference No:- TGS0174868

Expected delivery within 24 Hours