1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
kifflom [539]
2 years ago
9

Write a program to implement problem statement below; provide the menu for input N and number of experiment M to calculate avera

ge time on M runs. randomly generated list. State your estimate on the BigO number of your algorithm/program logic. (we discussed in the class) Measure the performance of your program by given different N with randomly generated list with multiple experiment of Ns against time to draw the BigO graph (using excel) we discussed during the lecture.
Computers and Technology
1 answer:
zalisa [80]2 years ago
8 0

Answer:

Explanation:

#include<iostream>

#include<ctime>

#include<bits/stdc++.h>

using namespace std;

double calculate(double arr[], int l)

{

double avg=0.0;

int x;

for(x=0;x<l;x++)

{

avg+=arr[x];

}

avg/=l;

return avg;

}

int biggest(int arr[], int n)

{

int x,idx,big=-1;

for(x=0;x<n;x++)

{

if(arr[x]>big)

{

big=arr[x];

idx=x;

}

}

return idx;

}

int main()

{

vector<pair<int,double> >result;

cout<<"Enter 1 for iteration\nEnter 2 for exit\n";

int choice;

cin>>choice;

while(choice!=2)

{

int n,m;

cout<<"Enter N"<<endl;

cin>>n;

cout<<"Enter M"<<endl;

cin>>m;

int c=m;

double running_time[c];

while(c>0)

{

int arr[n];

int x;

for(x=0;x<n;x++)

{

arr[x] = rand();

}

clock_t start = clock();

int pos = biggest(arr,n);

clock_t t_end = clock();

c--;

running_time[c] = 1000.0*(t_end-start)/CLOCKS_PER_SEC;

}

double avg_running_time = calculate(running_time,m);

result.push_back(make_pair(n,avg_running_time));

cout<<"Enter 1 for iteration\nEnter 2 for exit\n";

cin>>choice;

}

for(int x=0;x<result.size();x++)

{

cout<<result[x].first<<" "<<result[x].second<<endl;

}

}

You might be interested in
Will mark Brainliest!! What is the best hard disk compacity? Why?
choli [55]

Answer:

The SeaGate FireCuda is the best hybrid hard drive.

Explanation:

The SeaGate FireCuda is the best hybrid hard drive on the market. It can fit up to 2TB of data, and then its 8GB of solid state cache storage learns which data you use most, so that you can access it quickly. That speed boost is even sweeter when you consider that this drive spins at 7,200rpm.

3 0
2 years ago
Plz answer this....quickkkkk​
ioda
C - Puts a list of items into order
8 0
2 years ago
Read 2 more answers
What is an examlple of cyberbullying
Alex73 [517]

Answer:

sending rude text messages

Explanation:

3 0
3 years ago
Write a program that keeps track of a simple inventory for a store. While there are still items left in the inventory, ask the u
MissTica

Answer:no

Explanation:

3 0
2 years ago
Read 2 more answers
________ is digital textual information that can be stored, manipulated, and transmitted by electronic devices.
mars1129 [50]
E-text <span>is digital textual information that can be stored, manipulated, and transmitted by electronic devices. The term "e-text" stands for electronic text and it is used for any digital document written, read, transmitted or manipulated by electronic devices, such as smart phones, PCs, tablets,...The origins of the e-text are in the beginning of the Internet.</span>
7 0
3 years ago
Other questions:
  • An organization's contact information includes its _____.
    9·2 answers
  • How do you convert a decimal to binary?
    9·2 answers
  • If you were to create a new app for a smartphone or tablet that does not already exist, what would you create?
    10·1 answer
  • B) If you send me an email, then I will finish my program. If you do not send me an email, then I will go to sleep early. Theref
    10·1 answer
  • Explain each kind of pointer and for what it is appropriate.
    8·2 answers
  • This matches the domain name with the correct IP address:
    12·1 answer
  • PLEASE HELP!!!!
    6·2 answers
  • If a function doesn’t return a value, the word _________ will appear as its return type.
    6·1 answer
  • SeleCT all correct text​
    5·1 answer
  • Can someone give me an earsketch song of summer to turn in
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!