63 074
Assignments Done
99,1%
Successfully Done
In July 2018

Answer to Question #45586 in C++ for CT

Question #45586
Measure elapsed time for Bubble sort algorithm. Use at least 50 points of N to draw graph.
Expert's answer
#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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions