Reminder

  • If you haven't done so already, please fill out the COS 126 student survey. It will only take a minute. Otherwise your name will not get entered in our database, and you will not receive a grade in this course.

  • Goals

  • If you're new to programming, the goal of this week's assignment is to make sure that you can:

  • Read data from standard input and write to standard output (scanf, printf).

  • Use loops (for, while).

  • Use branches (if, else).
  • You needn't worry much about why Floyd's method works; instead concentrate your efforts on implementing the algorithm.

  • If you have lots of previous programming experience, your goal this week is to:

  • Introduce you to the C language, if you have learned another.

  • Understand why Floyd's method works, and appreciate its elegance. Think about other ways to compute the cycle length, and consider the amount of time and memory used by these methods.

  • Unix tip of the week

    The shell is the program that interprets your Unix commands. The shell tcsh has many nice features that will make using Unix easier. If you are a new Unix user, we highly recommend changing your shell with the following command:

    phoenix.Princeton.EDU% chsh
    
    You will be instructed to enter your Unix password. Then it will prompt you to enter your new shell. Carefully type
    /usr/princeton/bin/tcsh
    
    The chsh program on arizona is a bit flaky, so if it doesn't work, try again later. This will enable the following features:

  • The backspace key will work properly.

  • Use the up-arrow key to recall previous commands.

  • Use the Tab key to complete filenames. For example, instead of typing "gcc alongfilename.c", simply type "gcc alo<Tab>" and the shell will automatically complete the filename for you.

  • Testing

  • Here's a link to some hints on getting started with the assignment.

  • To test your code, run your program with the various parameters used in the assignment.

  • Also, you should run your program on different parameters of your own choosing. You can check your work by comparing your results with our reference programs. Type "trace126" or "cycle126" to run our version of the two programs.

  • Submission

  • Use the following submit command:
    submit126 1 readme trace.c cycle.c
    
    Do not substitute different file names. Be sure that every file you submit includes your name, login, and precept number.

  • Be sure that you do the following in your readme file:

  • Write your name, login, and precept number.

  • List whatever help (if any) that you received.

  • Describe any serious problems you encountered.

  • Do not exceed 80 characters per line. If you're unsure, print it out with the command "enscript126 readme", and make sure it is nicely formatted.
  • Here is a readme file template to get you started.


  • Enrichment Links

  • If you need pseudo-random numbers in real scientific applications, we recommend the Mersenne Twister.



  • Kevin Wayne