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
What is the most important trait of the first pilot project in the AI Transformation Playbook?
MissTica

Answer:

Succeed and show traction within 6-10 months.

Explanation:

Ai (Artificial Inteliigence), also known as machine intelligence, is a branch of computer science that is specialized in making smart machines that are capable of doing human tasks

AI Transformation Playbook is a guide to use AI in enterprises successfully, written by Co-founder of Google Brain, Andrew Ng. In his guide, he unveiled the steps that can be followed to successfully installing AI in enterprises, companies, etc.

The most important trait of the first pilot projects is that it succeeds and begins to show traction within 6-10 months.

In his guide, he summarised five steps to install AI in enterprises. The first step is to 'Execute pilot projects to gain  momentum.'

The most important trait of beginning with AI projects is that it succeeds first before being most valuable projects. The success is important as it will help to achieve familiarity and will help other people of the company to invest in this project more.

This success begins to show tractions within 6-12 months of its success.

8 0
3 years ago
Which of the following exhibit temporal locality: 1. Repetition control flow 2. Linear search on an array of integers 3. Accessi
Tom [10]

Answer:

1, 2 and 3

Explanation:

Temporary locality occurs when a program accesses an instruction or a  data, there is a high probability that this  same instruction or data will be accessed again soon.

6 0
3 years ago
A credit card can be a good way to pay when yo can’t afford something for a very long time? True or false
scoray [572]
False. Credit cards usually have high interest rates if you don’t pay them off right away. The only way to benefit from a credit card is if you pay it off by the due date monthly.
7 0
3 years ago
hi, I want to ask how do I change the Brainly to another country?, because I pressed the wrong Brainly button to my country​
Setler [38]

Answer:

I don't know maybe you should Uninstall

3 0
3 years ago
Read 2 more answers
What are the advantages and disadvantages of UTF-8 compared to ASCII?
Romashka [77]

Answer:

UTF-8 and ASCII both are the character encoding.

In a system,every character has some binary representation,these are the method to encode them.Earlier only ASCII was there, for every character it uses 8 bits to represent.In ASCII only 8 bytes were there i.e 2^8 that is 256.We can't represent number beyond than 127 so it generate a need for other encoding to get into,these drawbacks lead to Unicode,UTF-8.

As ASCII codes only uses a single byte,UTF-8 uses upto 6 bytes to represent the characters.So we can save characters which are as long as 2^48 characters. We can read this encoding easily by the help of shift operators and it is also independent of byte order.

As messages on internet were transferred over 7 bit ASCII messages,so many mail servers removed this encoding.    

6 0
3 years ago
Other questions:
  • What is the type of account and normal balance of allowance for uncollectible accounts?
    13·2 answers
  • Which keyboard feature is a form feed character?
    15·1 answer
  • What connector has 4 pins, is used for older IDE drives and some SATA drives, and can provide +5 V and +12 V power outputs?
    11·1 answer
  • A Unit of information containing the objects position, rotation, and scale values is called:
    13·1 answer
  • Assign jsonData with the parsed value of the stringData variable. Then, assign 29 to the points property in jsonData and assign
    13·1 answer
  • Write the document type declaration markup statement for an HTML5 file. Be sure to include the appropriate opening and closing b
    12·1 answer
  • create a function that has an argument is the triple jump distance. It returns the estimate of vertical jump height. The world r
    8·1 answer
  • Give me at least five main characteristic of irrigation equipment​
    8·1 answer
  • ASAP BRAINLIEST!!!
    6·1 answer
  • What is the first phone ever made?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!