following is the implementation of radix sort:-
//------------------------
----------
----------
----------
----------
----------
----------
----------
void radixsort(long data[],int n)
{
register int i, j, k, factor;
const int radix=10;
const int digits=10; //the maximum number of digits for a long
Queue<long> queues[radix]; //integer;
for(i=0, factor=1; i<digits; factor *=radix, i++)
{
for(j=0; j<n; j++)
queues[(data[j]/factor)%ra
dix].enque
ue(data[j]
);
for(j=k=0; j<radix; j++)
while(!queues[j].empty())
data[k++]=queues[j].dequeu
e();
}
}
//------------------------
----------
----------
----------
----------
----------
----------
----------
how can i add a counter in the coding to count the number of times major operations are performed in the algorithm? can somebody please help with that?
thanks....
Start Free Trial