->Homepage
->Schedule
->Courses
-->CS182
-->Tentative Schedule
-->Objectives
-->Quiz 1
-->Lab 1
-->Lab 2
-->Lab 3
-->Lab 4
-->Lab 5
-->Lab 6
-->Lab 7
-->Project
-->GE110
->Course Policies
->Electronic Submission
->Documentation Standards
->Old Exams
->C++ Examples
->MSVC++ Info
->Software
->Support Forum
->Unix Info
->Nature Photos

[Home]
[Rich][Home][Rich]
[Author]
CS182 -- Final Project

Fall 2003

Hydrogen is a colorless, odorless gas which, given enough time, turns into people. -- Henry Hiebert
Overview

A number of scientists, unwilling to consider a belief in a higher power, have been forced to devise an explanation for human existence. One popular explanation goes like this: "Anything, no matter how unlikely, is possible given a sufficient amount of time."1 In this assignment, you will attempt to apply this same reasoning to an event that is much more likely than the creation of human beings from hydrogen gas.

Procedures

It has been said that a monkey pushing keys at random on a typewriter could, given enough time, reproduce the works of Shakespeare. You should write a program that does the following:

  • Your program should generate a sequence of randomly selected lower-case letters and spaces.
  • Once the following sequence of letters has been generated: hydrogen is a colorless odorless gas which given enough time turns into people or eight hours has elapsed (whichever happens first), your program should stop generating the sequence of random characters and display the following:
    • The number of times the letter a appears in the sequence,
    • The number of times the letter b appears in the sequence,
    • The number of times the letter c appears in the sequence,
    • ...
    • The number of times the letter z appears in the sequence,
    • The number of times a space appears in the sequence,
    • The longest subsequence of characters matching the phrase above and the index value where the subsequence begins.
      For example, if your program generated the following sequence of random letters audshopifuzxhyvjoiawuehrjasdoijhchvjaoie, your program should indicate that the longest subsequence was hy and that the subsequence begins at index value 12.
    • The number of characters in the sequence your program generated. (2 in the above example)
    • An estimate of how much more time your program would need to generate the entire phrase give above. (If your program generated the phrase, your estimate should be 0.)
  • Your program should use the random function you created in lab 7.
Tips
  • You do not need to (and should not) store the sequence of letters generated by your program.
  • Consider using the ctime library to help you determine when to stop generating random characters.
  • Keep in mind that your computer can generate a lot of characters in an eight hour period. You may not be able to represent the number of characters generated as an integer or even a long double. You may decide to develop a technique for representing arbitrarily big numbers using a vector or list.
  • Since your program may run for up to eight hours, you should plan to complete your program at least one day before the due date so that you have sufficient time to run you program and analyze the results.
  • Have fun.
Just for Fun

For an extra challenge, you may wish calculate the probability of producing the given sequence on your first try.

Lab report (due 4:00pm, the last day of class)

Here is a template file to use as a starting point for this report.

Your lab report should be an independent document. That means that someone should be able to understand what you did and why without seeing anything other than your report. Your report should include:

  • Overview
  • Sample output produced by your program.
  • Your reaction (a couple of paragraphs on what you learned and what you thought about while working on this assignment)
  • Any suggestions you have for how the lab could be improved.
  • A summary of your activity log indicating how much time you spent on the assignment (following the template provided in the proj.xml template document). Please use the following categories:
    • Design
    • Coding
    • Debug (before you think it's working)
    • Test (after you think it's working)
    • Writing Report
    • Other
  • The Documented source code for your program.

As with any report you submit, correct spelling and grammar are required. In addition, your report should be submitted electronically following the Electronic submission guidelines. (You may wish to consult the XML help video and/or sample report before submitting your report.) Be sure to keep copies of all your files, in case something gets lost.

Your grade will depend on quality of design, clarity of code and documentation, as well as whether your program produces the correct results. If you have any questions, consult your instructor.

Acknowledgment

This laboratory assignment was developed by Dr. Chris Taylor.

1 Of course this fails to explain how "anything" came into existence in the first place, but this discussion is beyond the scope of this project.

Last Updated: Friday, 06-Feb-2004 15:55:04 CST