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
You found an image on the Creative Commons that you would like to use. How do you give credit to the author? *
Archy [21]
You need to write the author’s name
7 0
3 years ago
Read 2 more answers
Every nic has a unique address that consists of a 12-digit hexadecimal value. what is this address called?
Lyrx [107]
That address is called the MAC address 
6 0
4 years ago
Set of general format used to write program in any programming language?​
Novosadov [1.4K]

Answer:

hope you find it right

Explanation:

The process of writing computer instructions in a programming language is known as Coding.

A computer program is usually written by a computer programmer in a programming language. From the program in its human-readable form of source code, a compiler can derive machine code—a form consisting of instructions that the computer can directly execute.

That line of code is written in the Python programming language. Put simply, a programming (or coding) language is a set of syntax rules that define how code should be written and formatted. Thousands of different programming languages make it possible for us to create computer software, apps and websites.

In programming, code (noun) is a term used for both the statements written in a particular programming language - the source code , and a term for the source code after it has been processed by a compiler and made ready to run in the computer - the object code .

5 0
3 years ago
Each drop-down menu.
solniwko [45]

'Splitting' involves dividing a single column into multiple columns.

'Validation' involves checking the data for correctness. (there slight possibility I am wrong for this one)

I hope I provided some great assistance for you, have a good day, young programer.

7 0
3 years ago
A type of touch screen that can be up to four feet by six feet is a(n) _____. plasma screen multitouch interface Electronic Pape
zlopas [31]
<span>a multi touch interface</span><span />
5 0
3 years ago
Read 2 more answers
Other questions:
  • Design a Visual Logic flowchart for a program that prompts the user to enter ten numbers one at a time. After the user has enter
    10·1 answer
  • Consider an interface p ublic interface NumberFormatter { String format (in n); } Provide four classes that implement this inter
    15·1 answer
  • Samuel loves playing the violin, but he feels embarrassed after a classmate posts a video on a social networking site making fun
    6·2 answers
  • Select the qualification that is best demonstrated in each example. Trinity recommends investment strategies to customers. Laris
    10·2 answers
  • All who are interested in forex trading and bitcoin mining follow me for account management to all who are busy with work so i c
    14·1 answer
  • What episode and Season of Simpsons is this
    10·1 answer
  • In which of the following cases is the application of a nested loop not justified? When comparing two lists of integers When for
    14·1 answer
  • Which step do you think is most useful from big data life cycle and why?
    12·1 answer
  • If you have an unstable investment and after 5 years you have 100 dollars less than you started with, is your IRR positive or ne
    14·1 answer
  • Hello can someone help with the output of this please?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!