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
In PowerPoint, a type of chart that, rather than showing numerical data, illustrates a relationship or logical flow between diff
Lynna [10]

Answer:

A. SmartArt

Explanation:

SmartArt is a graphical tool used to visually communicate information.

8 0
3 years ago
If Scheme were a pure functional language, could it include DISPLAY ? Why or why not?​
VARVARA [1.3K]

Answer:

When Scheme is a pure functional language, it cannot include the function DISPLAY. Since the pure functional languages will return the same value whenever the same expression is evaluated, and the DISPLAY would be the output and thus it cannot be part of the purely functional language. Thus in the pure functional language we can evaluate the expressions with the same arguments and it returns the same value since there is no state to change.

Explanation:

4 0
3 years ago
Which statements accurately describe tropical rain forests
sattari [20]

The tropical rain forest is a forest of tall trees in a region of year-round warmth. An average of 50 to 260 inches of rain falls yearly. Rain forests belong to the tropical wet climate group.

Explanation:

  • The temperature in a rain forest rarely gets higher than 93 °F or drops below 68 °F. The average humidity is between 77 and 88%, rainfall is often more than 100 inches a year. In monsoonal areas, there is a real dry season.
  • Rainforests now cover less than 6% of Earth's land surface. Tropical rainforests produce 40% of Earth's oxygen.
  • About 1/4 of all the medicines we use come from rainforest plants. Curare comes from a tropical vine, is used as an anesthetic and to relax muscles during surgery. Quinineis used to treat malaria.
  • There are four very distinct layers of trees in a tropical rain forest. They are the emergent, upper canopy, understory, and forest floor.
  • The soil of the tropical rainforests is shallow, poor in nutrients and without soluble minerals. Years of rainfall have washed away the nutrients in the soil obtained from weathered rocks.
  • The tropical rain forest can be found in three major geographical areas around the world.
  • Central America in the the Amazon river basin.  Africa - Zaire basin, with a small area in West Africa. Indo-Malaysia - west coast of India, Assam, Southeast Asia, New Guinea and Queensland, Australia.
7 0
3 years ago
If the value of the expression,
mr Goodwill [35]

Answer:

<u>Arithmetic underflow</u>

Explanation:

Great question, it is always good to ask away and get rid of any doubts that you may be having.

Since the answer given is a negative. We can say the error that is seen here is an <u>Arithmetic underflow </u>error. This is because the answer given is a smaller absolute value which the computer cannot actually represent or save in its memory in the CPU. Therefore this is the closest representation of the arithmetic error displayed.

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

8 0
3 years ago
Many PC operating systems provide functionality that enables them to support the simultaneous execution of multiple applications
guapka [62]
The answer is multitasking. This is when the OS always programs to share resources to run at the same time.

If the applications were running on separate CPUs, then it would be multiprocessing.
3 0
3 years ago
Other questions:
  • Travis completes his assignments on a word processor. He wants to make sure that his documents are free from spelling or grammat
    9·2 answers
  • What does bam file stand for computer terms?
    9·1 answer
  • Which shape denotes a process to be carried out in a flowchart?
    7·2 answers
  • Write a Java program that prompts the user to enter integer values for the sides of a triangle and then displays the values and
    7·1 answer
  • Match each scenario to the absolute value expression that describes it. 1. the distance moved when going backwards five spaces i
    13·2 answers
  • 10 points!
    12·1 answer
  • Is there any quantum computer in India?​
    9·1 answer
  • There's an App for That!
    5·1 answer
  • The main part of your program has the following line of code.
    7·1 answer
  • What is a system of access control that allows only limited use of material that has been legally purchased?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!