

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


In class we discussed three different algorithms, each of different complexity, that solve the Maximum Contiguous Subsequence Sum problem. In this first programming assignment you will implement each of these algorithms [the O(N^3 ), O(N^2 ), and O(N) versions] and verify that the Big-Oh estimates are correct. This will be done by timing the actual running time of your algorithms and comparing that running time to the theoretically expected value for that algorithm based upon the size of the input data set. Note that all of these algorithms return the MCSS, the starting index, and the ending index, these values must be printed out as part of your results. One of your data sets should be an example from the book so that you can verify your algorithm correctly computes the MCSS. Generate a total of 5 different data sets (run each set of data on all three algorithms), one each of size 10, 100, 1000, 10000, 100,000 elements. Remember that the arrays must contain both positive and negative numbers!
On or before the due date you must submit, in a large envelope, the following: Hard copy of the source code. Hard copy of the output produced by your program. A compilable or executable version of your source code on a 3.5” floppy disk Hard copy of the write-up described below. On the envelope containing your material include the following: your name, your SS#.
You must include as a part of your lab a write-up describing your method, results, the big-oh verification and your conclusions. Your method refers to the technique that you used to determine the timing information, how you generated the test data. Type up the write-ups and make them look neat. Be sure to include a hard copy of the write- up even if it is also on the disk. Your lab write-up needs to cover the following areas:
goes here, the qualitative part comes later. This is where you will show the T(N)/F(N) calculations (possibly in tabular form) and the timing data that you empirically generated.
You need to have a total of 5 different arrays – each of which will be used with the O(n), O(n^2 ), and O(n^3 ) algorithms. The five arrays should have size 10, 100, 1000, 10,000, and 100,000 respectively (note: you may need to adjust these numbers downward or upward). The arrays should be randomly generated according to: C++: vector
You will need to determine the running times for each of the three algorithms for each of the five arrays. Thus, a total of fifteen data points will be generated, five for each algorithm. To determine how long the algorithm takes with each array the following code will need to be inserted into the programs: C++: //need to include time header file #include <time.h> // define a timing variable to be of type clock_t clock_t startTime; int elapsedTime; // start the timer running startTime = clock( ); // execute algorithm // stop the timer elapsedTime += clock( ) – startTime;