Question: For the following algorithm foo, explain what it computes, state what the input size for analysis is, state what basic operations should be counted for
For the following algorithm foo, explain what it computes, state what the input size for analysis is, state what basic operations should be counted for analyzing it, state exactly how many operations are executed as a function of the input size, and state the efficiency class to which it belongs. Show your work and explain how you arrived at your answers.
void foo(vector
Write a C++ program that implements the algorithm above, counts the number of basic operations, and outputs the input size and the count of basic operations to the cerr stream. Your program must accept the size of the array as a single command line argument, it must produce exactly one line to cout that prints the contents of the array, space separated, after foo has been called, and it must produce exactly one line to cerr that prints the input size, a space, and a count of the basic operations. A run of your program must look exactly like this:
$ ./program 5 -145175 -9166 119534 350670 975235 5 12345 (except that you will have different values, and 12345 is not correct). For large input size, you will almost certainly want to redirect cout to /dev/null. For this program, you will probably use random numbers. To generate high-quality pseudorandom numbers, better than simple rand() can produce. Include the chrono and random system libraries, and use this code:
const int MAX_RANDOM_VALUE = 1000000; default_random_engine get_next_value (static_cast
Use a plot of input size vs. basic operations, along with one or more standard functions properly scaled, to illustrate the analysis you did.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
