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
Design a program that asks the user to enter a string containing a series of single digit numbers with nothing separating them.
ruslelena [56]

Answer:

  1. def calcSum(d):
  2.    sum = 0
  3.    for x in d:
  4.        sum += int(x)
  5.    return sum
  6. digits = input("Please enter your digits: ")
  7. print(calcSum(digits))

Explanation:

The solution code is written in Python.

Firstly, create a function that take one input digit string (Line 1).

In the function, create a sum variable with initial value 0.

Use a for loop to traverse through each character in the digit string and in the loop use int method to convert each character to integer and add it to sum variable (Line 3-5) and return the sum as output.

Next, use input function to prompt user enter a digit string (Line 7).

Lastly test the function by passing the input digit as argument and print the result (Line 8).

7 0
3 years ago
Which option best describes the game Farmville? It is designed to educate players about virtual currencies. It is designed to ed
Levart [38]
The answer would be <span>It is designed to promote social interaction and community building.</span>
7 0
3 years ago
Read 2 more answers
The programming interface for a legacy motor controller accepts commands as binary strings of variable lengths.
victus00 [196]

Answer:

The answer is "Option a"

Explanation:

The given question is incomplete, that's why its correct solution can be defined as follows:

The above-given question is the part of the Binary Autocomplete, in which this Autocomplete function would be a full word or sentence after just a few other letters were entered into the system. It approach improves text taking appropriate on smartphone devices of particular because every letter should not be written in such a single phrase.  

3 0
3 years ago
What are the letter that go under each note?
gladu [14]

Answer:

A, B, C, D, E, F, G pls mark me brainliest see explanation below

Explanation:

those are the letters if you search up letters for music you can find them way easier than me explaining and you will also learn faster. please mark me brainliest

5 0
2 years ago
Read 2 more answers
Ellen's laptop has a built-in 802.11n-capable wireless NIC. The wireless NIC worked perfectly yesterday when she loaned it to he
Flura [38]

Answer:

The NIC is disabled in CMOS

Explanation:

CMOS refers to the Complementary Metal Oxide Semiconductor.  It is a technology that is used to generated integrated circuits.

It can be found in various types like microprocessors, batteries, etc

While on the other hand the NIC refers to the network interface controller in which the component of the computer hardware has connected the computer to its network. It can be done via wired and wireless.

Since in the given situation, it is mentioned that Ellen is not able to access the internet through wireless NIC neither it is visible in network connections nor it is shown in device manager so first she assumes that is nic is disabled in CMOS

and the same is to be considered

6 0
3 years ago
Other questions:
  • What is the 7 X 7 when referring to PowerPoint presentations?
    12·2 answers
  • Jimmy and his friends are creating a rock band and have decided to turn his garage into a recording studio. He wants to sell the
    9·2 answers
  • Identify the false statement.
    8·1 answer
  • Which actions help to protect a computer and keep it running properly? Check all that apply.
    10·1 answer
  • You are informed that all the users within the network are unable to access the Internet. You decide to start troubleshooting fr
    12·1 answer
  • Write the definition of a method min that has two int parameters and returns the smaller.
    9·1 answer
  • Besides the Computer Inventory and Maintenance form, what other documentation should you keep on each computer? How might you st
    8·1 answer
  • Tree diagrams are useful for
    12·1 answer
  • ____ steganography places data from the secret file into the host file without displaying the secret data when you view the host
    9·1 answer
  • Assignment 10 - 1/0 Streams and Files Create a C++ a program that will compute the average word length (average number of charac
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!