Question #45586
Measure elapsed time for Bubble sort algorithm. Use at least 50 points of N to draw graph.
1
Expert's answer
2014-09-03T04:19:51-0400
#include <cstdlib>#include "time.h"#include <stdio.h>#include <iostream> using namespace std; int a[10000]; int main(){    for(int i=0; i<50; ++i)    a[i]=rand()0;     float t=clock();    //Bubble sort    for(int i=0; i<50; ++i)    for(int j=i+1; j<50; ++j)    if(a[j]<a[i])swap(a[i],a[j]);     //Print array to screen    for(int i=0; i<50; ++i)    cout<<a[i]<<" ";    cout<<endl<<"time - "<<(clock()-t)/1000<<endl;     }

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!
LATEST TUTORIALS
APPROVED BY CLIENTS