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
why c is middle level language?

Description A long time ago in a galaxy far, far away, the country Mafghanistan had n cities and m old roads, where each road connected a pair of cities. Due to the treacherous mo

i need expression and its types with example programs in c++


Smugglers are becoming very smart day by day. Now they have developed a new technique of sending their messages from one smuggler to another. In their new technology, they are send

Define Generic Bitwise Operations? Bitwise operators only work on an incomplete number of types int and char. It turns out there's above one kind of int. In particular there's

#include long BixFunction(int x, int y = 5, float z = 5) { return(++x * ++y + (int)++z); } int main() { cout return 0; }

What if one forget the [] when deleteing array allocated through new T[n]? A: All life comes to a disastrous end. It is the programmer's responsibility not the compiler's to

Problem 1 What is the difference between function declaration and function definition? 2 Write a recursive function to find sum of even numbers from 2 to 10. 3 List some

#write a program that counts the number of occurances of the string in the n-th padovan string p(n)