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 statement is false? arrays may contain pointers. each entry in an array of strings is actually a pointer to the first char
konstantin123 [22]
<span>each entry in an array of strings is actually a pointer to the first character of a string

Each indice in an array of strings (which are actually each actually an array of char) is actually a pointer to the first (0th) char of a string.
</span>
4 0
3 years ago
What are the benefits of writing functions that use parameters and return List 2 please and explain what is return
Ratling [72]

<u>Answer and explanation:</u>

There are many benefits of writing functions that use parameters and return. Some of them are:

1. Flexibility: With functions having parameters, several values of the parameters can be used at invocation time thereby making the application flexible. For example, given the following function in Java.

<em>public void showName(String name){</em>

<em>    System.out.println("Your name is " + name);</em>

<em>}</em>

To call this method (function), the programmer could use various values for the name parameter used in the function like so:

showName("John");

showName("Doe");

If the function didn't have a parameter, it is possible it will only print a hardcoded name every time the function is called.

2. Scope Control: When a function is allowed to return a value, it helps to work around scope issues since variables declared within a function are limited to that function and do not exist outside the function. This means that the values of these variables cannot be used anywhere else outside the function in which they are being declared. However, if the function returns a value, the value can be used anywhere else in the program.

For example:

<em>public String getDouble(int x){</em>

<em>    int y = x * 2</em>

<em>    return y;</em>

<em>}</em>

The function above returns twice the value of the argument supplied to it. Since the integer variable y is declared within the function, it's value cannot be used outside the function. However, since the value is being returned by the function, it could be used anywhere the function is being called. Thanks to the return keyword.

3 0
3 years ago
Wanda manages an application that fluctuates in usage quite a bit. Sometimes it uses quite a few servers with lots of memory and
TEA [102]

Answer:

c. Elasticity

Explanation:

When referring to Cloud Servers this capability is known as Elasticity. It basically describes how able and efficient a server is to automatically implement resources and remove resources in order meet the specific amount of demand at any given moment. Many times a server will not have much demand but will still have all the resources being used by the server. Being able to remove these unused resources so that they are available for other usage is what makes the servers elastic.

8 0
3 years ago
According to chronology, arrange the steps that you need to take during the installation of a ram stick?
MAXImum [283]

Answer:

first off you need to take of the screws make sure its unpluged and you open up to see the mother bored

Explanation:

6 0
3 years ago
Which of the following statements are true regarding technology and learning? Select 3 options.
bekas [8.4K]

Answer:

<h2>Knowledge can be acquired throughout your life, through both formal and informal methods.</h2>

As long as a person is alive, they can keep learning. With the amount of knowledge available in the world, it is improbable that a person can acquire all of it before they pass on. It is therefore possible to acquire information until the day a person dies.

<h2>Changes in technology both enable and require lifelong learning.</h2>

Technology keeps changing and developing in order to make things better and more efficient. As such, humans need to keep learning for their entire lives or else they will be left behind as newer technology comes out. Take smartphones for instance, a lot of older grandparents have had to learn how to use them to keep in contact with with their families.

<h2>Virtual reality simulations are being used for training in industries like healthcare and the armed forces.</h2>

Virtual reality has improved the effectiveness of training in both the medical and armed forces industry because with training capable of being done in a virtual world, it can be more in-depth. For instance, medical students can use more realistic subjects to learn the intricacies of the human body and soldiers can embark on dangerous training missions without actually risking their lives.

5 0
3 years ago
Other questions:
  • Why is it important to explore an Integrated
    13·1 answer
  • Why isn't my brainly camera working? I got Brainly Plus and can't even scan questions. I've logged out, I've uninstalled and rei
    14·1 answer
  • Explain why Windows and Linux implements multiple locking mechanisms. Describe the circumstances under which they use spinlocks,
    13·1 answer
  • Write program to calculate the sum of the following series where in is input by user. (1/1 + 1/2 + 1/3 +..... 1/n)
    12·1 answer
  • Express 0.0005 x 10-4 farads as picofarads
    5·2 answers
  • What can a Word user do with the Customize Ribbon dialog box? Check all that apply.
    7·1 answer
  • A template class is a class in which ___________.
    15·2 answers
  • Should Manufacturers Include Extra Programs in Operating Systems for Computers and Mobile Devices?
    10·1 answer
  • Create an application named SalesTransactionDemo that declares several SalesTransaction objects and displays their values and th
    12·1 answer
  • Deleting messages keeps them in the mailbox and on the server. How can they be removed from the server to reduce the quota?
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!