Dear all, I have created a code for QuicSort algorithm with random numbers and time executation but now I want to do for Countin sort And I don't know, Can anybady help me based in this example. Thanks
include <iostream>
include <conio.h>
include <time.h>
include <stdlib.h> //srand and rand functions
using namespace std;
void add_random_numbers ( long arr[], long b );
void QuickSort( long vektori[], long left, long right);
long const MADH_MAX_VEKTORIT = 110000;
int main()
{
long random_vector[MADH_MAX_VEKTORIT];
long vector[] = {1000, 10000, 15000, 25000, 30000, 45000, 50000, 60000, 75000, 90000, 100000};
long num_elem;
clock_t tn, tp;
srand( time( NULL ));
cout << "AlgorithmttNumbers_of_emelmentstttTime(s)n";
cout << "--------tt-------------------tt-------n";
for(long i = 0; i < 11; i++)
{
num_elem = vector[i];
add_random_numbers(random_vector, num_elem );
tn = clock();
QuickSort(random_vector, 0, num_elem );
tp = clock();
cout << "Quick ttt"<< num_elem << "ttt" << (tp - tn)/(double)CLOCKS_PER_SEC << endl;
}
getchar ();
return 0;
}
void add_random_numbers( long arr[], long b )
{
for( long i = 0; i < b; i++ )
arr[i] = rand();
}
void QuickSort(long vektori[],long left,long right)
{
int flag=1;
long i,j,k,temp;
if(left<right)
{
i=left;
j=right+1;
k=vektori[left];
while(flag==1)
{
while(vector[++i]<k &&i<=right);
while(vector[--j]>k &&j>=left);
if(i<j)
{
temp=vektori[i];
vector[i]=vector[j];
vector[j]=temp;
}
else flag=0;
}
temp=vector[left];
vector[left]=vektori[j];
vector[j]=temp;
QuickSort(vektori,left,j-1);
QuickSort(vektori,j+1,right);
}
}