Radix sort - c program, C/C++ Programming

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];

                }

}

Posted Date: 10/19/2012 3:04:50 AM | Location : United States







Related Discussions:- Radix sort - c program, Assignment Help, Ask Question on Radix sort - c program, Get Answer, Expert's Help, Radix sort - c program Discussions

Write discussion on Radix sort - c program
Your posts are moderated
Related Questions
i didnt no how to write and how to implement and the programming can be done in C and execution should be done in UNIX

Q: But operator overloading makes class look ugly; isn't it assumed to make my code clearer? A: Operator overloading makes life simpler for the users of a class, not for develop

switch statement

Define Static Storage Class in C Programming? The Static declarations have distinct and important uses. This allows the local variable to keep its previous value when the block

Explain about the Character Constants in c language? The character constant is a single alphabet and a single digit or a single special symbol enclosed within a pair of single

Call by reference: Arguments to a function can be passed in two way; one by call by value and other by call by reference.  Call by value is passed either through a constant

What is Namespace and Explicit container Namespace - Namespaces are used to group entities such as objects, classes and functions under a name. Explicit container.

Project Description: I need to convert AFL code of Amibroker to DLL plugin to hide original formula, and also to protect the DLL and making it hardware locked. I need to wrap th

I have a program for school and I am not understanding why one of the variables gets skipped or the arithmetic operators aren''t having any effect as I have tryed defining it sever