CSCI P415/515 Fri Jan 6 15:18:04 EST 2012 [SDJ]

Homework Assignment

This class uses a version-control system called Subversion (SVN). We do not need all of SVN's functionality, it just serves mainly as a homework depository. This assignment has three parts. For P415 students, Part C is optional.

Part A. Meet SVN

Follow the instructions for using SVN in P415/P515 [HTM] to create a working copy of your homework area, In subdirectory you will find a text file, profile.txt. Edit this file, providing information about yourself; for instance,
P415/515 Participant Profile
NAME     :  Steve Johnson 
LOGIN-ID :  sjohnson 

c211, c343, c335, c241, c311, p436, b441&2 LIST COMPUTER SCIENCE COURSES YOU ARE TAKING :
This course satisfies distributional requirements for my BS degree. Also, I'm interested in programming language implementation and am curious about the issue of compiler correctness.

  • Post your local copy of profile.txt to the SVN repository. according to the SVN Instructions
    svn commit -m "hw0" profile.txt
    Sending        0.txt
    Transmitting file data .
    Committed revision 332.

    Part B – Write an Array-Reverse Procedure

    Below is an incomplete C program that reads list of numbers into an array, reverses those numbers in place, and outputs the results.

    #include <stdio.h>
    int i, n, a[1000000];
    int test_in () { 
      while (!feof(stdin)) { scanf("%d\n", &a[n]); n = n+1; }
      return( n );
    void test_out (int n) {
      for (i = 0; i < n; i++) { printf("%d\n", a[i]); }
    void reverse () {
       – Reverse the order of the first n numbers in array a
    int main () {
      n = test_in();
      return ( 1 );

    There is a copy of this program at 0/rev/src/rev.c in your SVN directory, as well as a Makefile and other ammenities, including automatically generated Doxygen documentation in subdirectory 0/rev/doc/code/index.html.

    1. Design the body of the reverse() procedure as specified in red above.

    2. Carefully code your design with the goal of correctly implementing your design on the first try, without testing it. So design carefully, and jot down what you are thinking.

    3. Compile your code, giving the executable object the name rev. You may need to re-compile to get rid of syntax errors, but again, do not test your solution.

    4. Copy your rev to the rev/bin directory.
    Your rev must be a stand-alone, self-contained executable object that runs on a CS Network Linux machine. The command rev should read a list of white-space separated numbers from standard input and write those numbers in reverse order to standard output. This will be demonstrated in class. You should be able to re-direct input and output to files with the command
    rev < in-file > out-file

    NOTE: If you do not know C or C++ write a program that reverses an array in the language of your choice, excluding scripting languages like Python. Unless your result is a stand-alone, self-contained executable object, do not copy it to the rev/bin directory.

    Part C – Testing (P515 Students)

    Once the solutions have been turned in, the collection will be distributed to the class. Set up an environment for testing each of the rev.

    Test only for correct reversing of valid inputs. No provisions are specified for invalid inputs.

    You will be provided with a pre-formatted file to report your results.