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
Explain the consequences of using bits to represent data.
neonofarm [45]

Answer:

Each description of a PC needs to clarify how the PC handles data: numbers, text, pictures, sound, films, directions.

Using bits to represent data implies that the computer has to use a lot of memory since every character has a group of bits representing it.

The PC is an electronic gadget. Every one of its wires can either convey electric flow or... not convey current. Thus, similar to a light switch, it sees just two states. Incidentally, this is sufficient to make the entire thought work. Indeed, any framework that can speak to in any event two states can speak to data. Take, for instance, the Morse code that is utilized in telecommunication. Morse is a sound transmission framework that can convey a short signal (spoke to by a dab) and a long beeeeeep (spoke to by a scramble). Any letter or number can be spoken to by a mix of these two images. Snap here to see a Morse interpreter.

Explanation:

Essentially with PCs. To speak to a number, we utilize the parallel number-crunching framework, not the decimal number framework that we use in regular day to day existence. In the double framework, any number can be spoken to utilizing just two images, 0 and 1. (Morse is nearly, yet not exactly (because of the delays between letters) a paired framework. A framework firmly identified with Morse is utilized by PCs to do information pressure (more about this later).

7 0
2 years ago
What is meant by editing a document​
Doss [256]

Answer: “Editing” in general means fixing problems in a written document so that it has no mistakes and is easy to read

Explanation: Yeah

5 0
2 years ago
Read 2 more answers
What is unique about the TODAY and NOW functions?
Degger [83]

Answer:

The formula does not require arguments.

Explanation:

One of the programs or software that runs on a computer is Microsoft Office programs. One of these programs is called Microsoft Excel. It is a spreadsheet program where calculations can be made, graphs, diagrams can be plotted and drawn as well.

In other to utilize Microsoft Excel properly, we make use of what we call FUNCTIONS. Functions in Microsoft Excel are defined as formulas, that have already been prepared or created before hand in the Microsoft Excel program so that we can be able to used Microsoft Excel properly and efficiently. Functions may or may not require ARGUMENTS to carry out necessary calculations.

An ARGUMENT is a number or variable that functions require to carry out or do their calculations.

Examples of the functions found in Microsoft Excel are the TODAY and NOW functions. These two functions are used in spreadsheets on Microsoft Excel with regards to Date and Time.

TODAY function is used to give us or update the current or present date while the NOW function gives us or updated the current date and time.

The uniqueness or similarities between the TODAY and NOW functions is that their formula do not require arguments.

3 0
2 years ago
Read 2 more answers
The picture that graphically represents the items you use in Windows is called a/an
Novosadov [1.4K]
The answer to this is Bulls icon
6 0
3 years ago
While a computer is running the operating system remains in memory. true or false?
MrMuchimi
While a computer is running the operating system remains in memory is true.
8 0
3 years ago
Other questions:
  • Write a function called calculate() that accepts three integer Numbers as arguments, compute these values : Sum and Product and
    7·1 answer
  • With a patent on drug Z27, why would Able Drug Company charge customers $7 per 100 units even though its cost of producing 100 u
    5·2 answers
  • Please answer this I know that no one else does but I can't think right now
    10·1 answer
  • What feature of Windows Server allows for agentless authentication?
    7·1 answer
  • You have four DCs in your domain. Active Directory appears to be corrupted on one of the DCs, and you suspect a failing hard dri
    5·1 answer
  • What is the cffa act
    5·2 answers
  • All of the following are used to fund private schools except ______
    14·2 answers
  • Write a function in Java to implement the following logic:
    13·1 answer
  • Write a method for the Invitation class that accepts a parameter and uses it to update the address for the event.
    9·1 answer
  • What is the digital revolution and how did it change society?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!