CS 202 - Homework 1 - 9/12/07

Due: Monday, 9/17/07, in class (or by 2pm the latest)

On the first page, write your own name as well as the names of the students with whom you collaborated. Remember that you may discuss the problems with other students but must write them up individually and may not refer to current or past solutions. Please write legibly!
  1. (19 points) Martin, chapter 2, problems Clarification: In problems 2 and 7, the number is not given in decimal but in bases 5 and 16 respectively.

  2. (15 points) Tanenbaum, appendix A, problems 3-6
    (the problems in 4th and 5th edition are identical)

  3. (15 points) Write a program that counts in decimal and binary from 0 up to a given number. You can use any programming language you want, but you may not use any built-in functions for printing in binary or converting to binary. Example (using Java):
    % java BinaryCount
    usage: java BinaryCount <limit>
    
    % java BinaryCount 4
    decimal binary
    0       0
    1       1
    2       10
    3       11
    4       100
    
    % java BinaryCount 17
    decimal binary
    0       0
    1       1
    2       10
    3       11
    4       100
    5       101
    6       110
    7       111
    8       1000
    9       1001
    10      1010
    11      1011
    12      1100
    13      1101
    14      1110
    15      1111
    16      10000
    17      10001
    

    If your programming skills are rusty, I can provide a Java skeleton file for a 3-point penalty. For a point of extra credit, make the output right-aligned.
    Hand in a printout of your code and some sample output that demonstrates that your program works (copy and paste from the terminal window into a text editor).

  4. (1 point) How much time did it take you to complete this assignment?
Note: For the programming assignments in this course, I suggest you create a directory 'cs202', make it unreadable to others, and create a subdirectory for each homework:
benjerry:~$ mkdir cs202
benjerry:~$ chmod go-rwx cs202
benjerry:~$ cd cs202
benjerry:~/cs202$ mkdir hw1
benjerry:~/cs202$ cd hw1