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
find the minimum total number of shelves

Project Description: We want to generate premium numbers for one of our application. What we need is: A program that generate 2, 3, 4, 5, 6, 7, 8 digits premium numbers

#include using namespace std; void print(int marks_arr[],int cnt) { int ind[cnt]; int i=0; int j=0; int k=0; int s=0; for(k=0;k { ind[k]=0; } int cnt1=0; for(i=0;i

#question.conversion of tree into binary tree.

write a simple c++ program to implement a stack: 1. push 2. pop

#include #include using namespace std; class Book { private: string title; int iD; int year_pub; string author; public: string getTitle(); int getId(); int getYear_Pub(); st

We need an E Commerce site likefifacointrader. you must have experience with that kind of work You have to show a sample of work like that site. Skills required are C Prog

Convert coordinate: class rect{                 private :                 float  x,y;                   public :                 void  input()

Define Passing Structure to a Function? A structure is able to be passed as a function argument identical to any other variable. If we are merely interested in one member of a

The for Loop For loop is the controlled form of loop. The general format of this : for( initialize ; test ; update)                  {                     statements;