Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clock_t begin,end;
- double time_taken,time_taken2;
- int *p=(int*)malloc(200000*sizeof(int));
- int *s=(int*)malloc(200000*sizeof(int));
- for(int i=0;i<3;i++)
- {
- srand(time(NULL));
- if(fptr == NULL)
- {
- printf("Error!");
- exit(1);
- }
- for(int i=0;i<NO_DATA;i++)
- {
- p[i]=rand();
- s[i]=p[i];
- }
- begin=clock();
- straight_insert_int(p,NO_DATA);
- end=clock()-t;
- time_taken=(double)(end-begin)*1000/CLOCKS_PER_SEC;
- printf("Str_ins attempt %d Completed!n",i);
- fprintf(fptr,"tExecution time of %d str_ins: %1d msn",i,(int)time_taken);
- begin=clock();
- quicksort_int(0,NO_DATA,p);
- end=clock();
- time_taken2=(double)(end-begin)*1000/CLOCKS_PER_SEC;
- printf("Quicksort attempt %d Completed!n",i);
- fprintf(fptr,"tExecution time of %d quicksort: %1d msnn",i,(int)time_taken2);
- }
- fclose(fptr);```
- I am expect the output of qsort ALONE to be ~30ms and that's correct.
- I am expect the output of insertion sorting ALONE to be ~2800ms and that's correct.
- I am expect the output of insertion sorting & qsort to be ~2800ms and ~30ms and it is ~2800ms ~0-16ms.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement