Assigned | Thurs Sept. 24, 2003 |
Program Due | Thurs Oct 9th, 2003 at 11:59pm
Students are encouraged to complete this assignment by the original due date of Tues Oct 7th to allow sufficient time for exam preparation |
Design Due | Thurs Oct 2nd, 2003 at 11:59pm |
Updates | Fri, Sept 26th
There was a discrepancy between the data file description and the example data file which has been corrected. The data file will contain the words "Head" or "Tail". |
One important aspect of analyzing such a sequence is the number and lengths of the embedded "runs". A "run" is a sequence of consecutive Heads or Tails. For example, in the sequence HHHHTTHHTTTHT, there is a run of 4 Hs, a run of 2 Ts, a run of 2 Hs, a run of 3 Ts, a run of 1 H and finally a run of 1 T.
We will count the number of runs of each length for both Heads and Tails. In theory, if we toss a fair coin N times, there is a (very small, teeny, tiny) non-zero probability that all N tosses will be Heads or all N tosses will be Tails. Therefore, in theory the longest possible run for N tosses is N. In an award-winning paper (College Math Journal, Vol 21, 1990), Mark Schilling calculates that the expected longest run for N tosses is the integer closest to log2(N / 2) plus or minus 3, which is much less than N. Our program will help validate Mark's theory.
In addition to the frequency and length of the runs, your program will analyze the sequence of outcome to count or calculate the following
Your program will accept a single command line argument which is the name of the file that contains the outcomes of an unknown number of tosses of a fair coin. The format of the data file is given below. Your program must use vectors and may not use arrays.
Your program must contain the following functions. The code for these functions must be found in Coins.cpp. Their prototypes and function header comments must be found in Coins.h which should be included in Proj2.cpp. The names of the functions are left to you, but must follow our coding standards. The parameters and return type for each function are also left to you, but you must carefully consider how each parameter should be passed. Other functions are permitted as you see fit to achieve a good top-down design.
For this project, you will be responsible for providing your own makefile. Typing "make" should compile and link all files for your project. Your makefile should also support the commands "make clean" and "make cleanest". If you start with the makefile for project 1, the changes for project 2 are straightforward.
The grade for this project will be broken down as follows. A more detailed breakdown will be provided in the grade form you recieve with your project grade.
You can check to see what files you have submitted by typing
More complete documentation for submit and related commands can be found here.
Remember -- if you make any change to your program, no matter how insignificant it may seem, you should recompile and retest your program before submitting it. Even the smallest typo can cause compiler errors and a reduction in your grade.
Avoid unpleasant surprises!
Be sure to use the submitmake and submitrun utilities provided
for you to compile, link and run your program after you've submitted it.