Docsity

Programming Assignment 1 - Computer Science II - Spring 2001 | COP 3503, Assignments of Computer Science

Toggle sidebar
bg1
COP 3503H – Spring 2001 – Programming Assignment #1
Points: This assignment is worth 100 points. [program 60pts – write-up 40 pts]
Due Date: Thursday February 15, 2001 in class
Objective
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(N3), O(N2), 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!
Submission of the Assignment
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#.
Write-up
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:
1. Purpose: Describe the purpose of the experiment. What is it that you are attempting to
do? This is where you describe your hypothesis, i.e., what it is that you are trying to
prove.
2. Method: Describe the technique that you employed to run your experiment. Here you
need to explain the details of how you performed you experiment. Explain the rationale
for why you chose this method.
3. Empirical Results: Describe in quantitative terms the results of your experiment. This is
where you show the data and the analysis of that data. For our purposes here, you will
need to show all of your data (although, in general, this is rarely done). The analysis of
the data will be done in two ways: quantitative and qualitative. The quantitative part
1
pf3

Partial preview of the text

Download Programming Assignment 1 - Computer Science II - Spring 2001 | COP 3503 and more Assignments Computer Science in PDF only on Docsity!

COP 3503H – Spring 2001 – Programming Assignment

Points: This assignment is worth 100 points. [program 60pts – write-up 40 pts]

Due Date: Thursday February 15, 2001 in class

Objective

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!

Submission of the Assignment

 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#.

Write-up

 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:

  1. Purpose: Describe the purpose of the experiment. What is it that you are attempting to do? This is where you describe your hypothesis, i.e., what it is that you are trying to prove.
  2. Method: Describe the technique that you employed to run your experiment. Here you need to explain the details of how you performed you experiment. Explain the rationale for why you chose this method.
  3. Empirical Results: Describe in quantitative terms the results of your experiment. This is where you show the data and the analysis of that data. For our purposes here, you will need to show all of your data (although, in general, this is rarely done). The analysis of the data will be done in two ways: quantitative and qualitative. The quantitative part

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.

  1. Analysis: Describe the results of the experiment in qualitative terms (using the quantitative results as justification). Does the empirical data support your hypothesis? This is also where you will need to explain any deviations in your experimental set-up from what you had originally proposed (i.e., why didn’t you use an array of 100, elements for example).
  2. Conclusions: Does the analysis of the empirical data prove that your hypothesis was true? If it does, how accurate do you expect the results to be? If it doesn’t explain why it didn’t. If it didn’t, was the experiment flawed in some fashion – can you suggest a different experiment that might better support your hypothesis.

Details

 Generating the arrays

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 data( size); for (int i = 0; i < size; i++) data[i] = rand ( ) % 100 – 50; Java: int [ ] data = new int [size]; for (int i = 0; i < size; i++) data[i] = (int) ((Math.random( ) * 100) – 50); Replace “data” with the name of each array. Values in the array will range from –50 to +50, vary this if you want.

 Timing

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;