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
Question 1 What are the different steps in executing a C program? Explain Question 2 What are the commonly used input/output functions in C? How are they accessed?

At a shop of marbles, packs of marbles are prepared. Packets are named A, B, C, D, E …….. All packets are kept in a VERTICAL SHELF in random order. Any numbers of packets with thes

A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your task is to convert S to palindrome

Develop a Student class that has the following header file: #ifndef STUDENT_H #define STUDENT_H #include #include #include using namespace std; class Stu


Define global variable in c++ program: How to define a global variable and need of global variable in c++ program. int main() {    int m=20;    clrscr();    for

Program of file data: FileData::FileData( ffblk& blk ) :     fileName( blk.ff_name ),     fileDate( (blk.ff_fdate >> 5) & 0x000F,               blk.ff_fdate & 0x0001F

i need amibroker afl to dll plugin

What happens while a derived-class object is developed & destroyed? A: Space is allocated (on the heap or the stack) for the full object (i.e. adequate space to store the data m

Explain Formatted Input Output with File Pointer? Likewise there are equivalents to the functions scanf and printf which write or read data to files. These are called fscanf a