CSOC 2436: HW3

Your Task:

Complete this C++ program to conduct experimental analysis for project P-4.60 and P-4.61 from the book (Page 187). You are already provided with these algorithms in the c++ file

Implementation Detail:

Inputs and outputs

Your program will take 3 arguments.

For example, if input arguments are:

$ ./HW3 p1 p1.txt 6

It means we want to test the run time of prefixAverage1 with input size 10^1 (10 to the power of 1), 10^2, all the way up to 10^6. Your program should keep track of the amount of time needed to complete the algorithm, in milliseconds. Perform Log10 on your time, then write the numbers into the file name specified, one number per line. (Means there will be 6 lines, each line a number)

* For the function example5, you should initialize two arrays of same size.

plots

In addition to the textual output as per usual, you will also need to plot some plots. The plot should look similar to the one below for these code fragments:
Sample Plot
Notice the plot is in log-log scale, with x-axis as the input sizes and y-axis the time taken to complete. The input size parameter of your plot should be kept similar to the one above, ranging from 10^1 up to 10^6. (contact us if you are having difficulty running 10^6)

A total of 4 plots should be generated. Each plot also should be named as following:

  1. plot_1.png should contain the comparative results of p1 and p2 in one plot
  2. plot_2.png should contain the comparative results of e1 and e2 in one plot
  3. plot_3.png should contain the comparative results of e3 and e4 in one plot
  4. plot_4.png should contain the individual results of e5 as a single plot

You are free to generate the plots using tools of your choice: R, Matlab, Excel, etc… However, we expect the plots to be submitted in png format.

Here is some example output files.

Timing

Use the following function for timing:

clock_t current_clock = clock();

Submit your assignment:

There won't be any test scripts this time as the timing for everyone is expected to be slightly different. Please name your directory and source file correctly.

Create a directory on the Linux server, its name must be hw3

$ mkdir hw3

Change your current directory to the hw3

$ cd hw3

Compile the program

$ g++ HW3.cpp -o HW3