Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. clock_t begin,end;
  2. double time_taken,time_taken2;
  3. int *p=(int*)malloc(200000*sizeof(int));
  4. int *s=(int*)malloc(200000*sizeof(int));
  5. for(int i=0;i<3;i++)
  6. {
  7. srand(time(NULL));
  8.  
  9. if(fptr == NULL)
  10. {
  11. printf("Error!");
  12. exit(1);
  13. }
  14.  
  15. for(int i=0;i<NO_DATA;i++)
  16. {
  17. p[i]=rand();
  18. s[i]=p[i];
  19. }
  20.  
  21. begin=clock();
  22. straight_insert_int(p,NO_DATA);
  23. end=clock()-t;
  24. time_taken=(double)(end-begin)*1000/CLOCKS_PER_SEC;
  25.  
  26. printf("Str_ins attempt %d Completed!n",i);
  27. fprintf(fptr,"tExecution time of %d str_ins: %1d msn",i,(int)time_taken);
  28.  
  29.  
  30. begin=clock();
  31. quicksort_int(0,NO_DATA,p);
  32. end=clock();
  33. time_taken2=(double)(end-begin)*1000/CLOCKS_PER_SEC;
  34.  
  35. printf("Quicksort attempt %d Completed!n",i);
  36. fprintf(fptr,"tExecution time of %d quicksort: %1d msnn",i,(int)time_taken2);
  37.  
  38.  
  39.  
  40. }
  41. fclose(fptr);```
  42.  
  43. I am expect the output of qsort ALONE to be ~30ms and that's correct.
  44. I am expect the output of insertion sorting ALONE to be ~2800ms and that's correct.
  45. 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