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
What is an IF statement used for?
kiruha [24]

The IF statement is a decision-making statement that guides a program to make decisions based on specified criteria. The IF statement executes one set of code if a specified condition is met (TRUE) or another set of code evaluates to FALSE.

8 0
2 years ago
QUESTION 4 of 10: True or False: According to the reading, investors care about your love for your business.
mixer [17]

Answer:

false

Explanation:

5 0
2 years ago
Read 2 more answers
Question 3 (2 points)
jeyben [28]

Answer:

The energy source that does not use heat in the process of converting it to electricity is;

c. Sunlight

Explanation:

In converting Sunlight energy source to electricity, the photons in the light from the Sun excite electrons in the solar cells silicon layers, such that the electrons travel from n-type silicon layer to the p-type silicon layer creating electric potential energy that does work as the electrons flow back in the form of electricity from the p-type to the n-type silicon layer through an external circuit

7 0
2 years ago
Write a question that the database will understand. Which records do not contain "sold"?
astraxan [27]

Answer:

b

Explanation:

b

4 0
2 years ago
Simone needs to add a query for multiple tables in her database. She is using Access 2016. Which tab should she use to add the q
pshichka [43]
Database tools should be the answer idrk
4 0
3 years ago
Other questions:
  • You can clear a log file simply by redirecting nothing into it. true or false?
    13·1 answer
  • Select all that apply.
    8·2 answers
  • The code segment below uses the procedure IsPartOf (list, item), which returns true if item appears in list and returns false ot
    13·1 answer
  • The Quick Access Toolbar cannot be customized and have extra commands added to it
    5·1 answer
  • What do you mean by data sequencing​
    13·1 answer
  • what are the benefits of VolP? select all that apply. A:cheaper printings B:clearer calls C: faster download D: increased effici
    11·2 answers
  • Help giving points mark BRAINLEST
    5·1 answer
  • Write the header file Stadium.h for a Stadium class. The Stadium class has the following data members: 1) an array of 1000 Seat
    7·1 answer
  • Evie clicks through her presentation slides and realizes they all have transition effects coming from the same location, from th
    13·1 answer
  • Truth or dare????????????
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!