Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 132,147 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,938 people online right now. Registration is fast and FREE... Join Now!




R@dix sort

 
Reply to this topicStart new topic

R@dix sort, urgent help needed

Princess.
post 7 Oct, 2008 - 07:50 AM
Post #1


New D.I.C Head

*
Joined: 10 Sep, 2008
Posts: 6

Hi friends..i have written this function for radix sort smile.gif But as usual there are errors!! plz cud u modify the code and also add the void main to it...
CODE
# define NUMLETS 5
void radixsort(int x[],int n)
{
int front[20],rear[10];
struct
{
int info;
int next;
}node[NUMLETS];
int exp,first,i,j,k,p,q,y;
/*Initialize the linked list*/
for(i=0;i<n-1;i++)
{node[i].info=x[i];
node[i].next=i+1;
}
node[n-1].info=x[n-1];
node[n-1].next=-1;
first=0;
for(k=0;k<5;k++)
{
rear[i]=-1;
front[i]=-1;
}
/*processing each element of the list*/
while(first!=-1)
{
p=first;
first=node[p].info;
exp=power(10,k-1);
j=(y/exp)%10;
q=rear[j];
if(q==-1)
front[j]=p;
else
node[q].next=p;
}

for(j=0;j<10&&front[j]==-1;j++)
;
first=front[j];
while(j<=9)
{
for(i=j+1;i<10&&front[i]==-1;i++)
{
if(i<=9)
{
p=i;
node[rear[j]].next=front[i];
}
j=i;
}
node[rear[p]].next=-1;
}
/*copy back to original array*/
for(i=0;i<n;i++)
{
x[i]=node[first].info;
first=node[first].next;
}
}
User is offlineProfile CardPM

Go to the top of the page

jjsaw5
post 7 Oct, 2008 - 07:37 PM
Post #2


I vill break you

Group Icon
Joined: 4 Jan, 2008
Posts: 1,364



Thanked 6 times

Dream Kudos: 125

Expert In: HTML, CSS, Database,

My Contributions


How are we supposed to know what errors this is getting???


You are going to need to post them.
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/21/08 01:16PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month