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]
3 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]3 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
Which type of weathering creates karst topography?
pentagon [3]
The answer is c carbonation
8 0
4 years ago
Describe business benefits of using wireless electricity?
Triss [41]

Answer:

To put it simply, the main benefit for a business to use wireless electricity is money.

Explanation:

Assuming that the company in question can solve specific hurdles such as Microwave Interference and Implementation costs. Then they would save a huge amount of money in the mid to long term since wireless electricity needs very little landscape and does not need cables and transmitting towers as opposed to traditional electrical systems.

Hope you have found this explanation helpful and If you have any more questions please feel free to ask them here at Brainly, We are always here to help.

3 0
3 years ago
Who made computer ? Which year?
myrzilka [38]

Answer:

The first computer that resembled the modern machines we see today was invented by Charles Babbage between 1833 and 1871.

8 0
3 years ago
Read 2 more answers
What is one pass of a coding sequence called?​
Romashka-Z-Leto [24]

One pass code is final version of executable file for end user with zero error. While compile the software it give Error it give the list of error to end user further to address the issue.

<u>Explanation:</u>

In computer pass of a code is used in compiler mode of programing languages. Normally end user after completing the software development he or she will compile the software programs.

So as result compiler will  pass code in multiple sequence and make the software as executable file as standalone or execute file which executable software can understanding language.

3 0
3 years ago
Read 2 more answers
Can the teacher provide your feedback through Google Classroom?
ella [17]

Answer:

Yes

Explanation:

The teacher always answers all queries if she/he is online and the question u ask is understandable

4 0
3 years ago
Read 2 more answers
Other questions:
  • Which connector is most commonly used to connect printers to desktop pc systems?
    10·1 answer
  • Jeremy, a newly appointed assistant Director, is excited about his job. the director of the movie has assigned him the responsib
    6·1 answer
  • Alter the line of (10, 20) and (18, 30) en dpoints by (2, 3) scale factor, then move it by (5, 9) translate factor using matrix
    13·1 answer
  • How does a main program recieve info from a function in c++?
    6·1 answer
  • Handouts are pages of your presentation that you print and distribute to your audience
    10·1 answer
  • LensForAll is a company that sells affordable contact lenses on its website. The CEO of the company realizes that an app must be
    9·1 answer
  • Which statement creates a StudentIDs object given the following code: public class StudentIDs&gt; { private TheType item1; priva
    15·1 answer
  • Who knows my sister better?
    15·2 answers
  • Which types of online reading tools are available within the CloseReader? Check all that apply.
    11·1 answer
  • What is a key differentiator of Conversational Artificial Intelligence (AI)
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!