Spring Semester 2008

January 28, 2008 – May 2, 2008

Assignment 1: Warmup

Out on: January 28, 2008
Due by: February 4, 2008, noon (before lecture)
Collaboration: None

Overview

The first assignment is mostly a warmup exercise, giving you a chance to play with boxes, Unix, and other stuff we covered in the first week.

Problem 1: Boxes of Problems

Assume you have an infinite supply of the "boxes" we used in the first lecture for numeric computations: constants, addition, multiplication, and square root. Now consider the following:

  1. Define each of the "boxes" in this list: twice which doubles its input, square which squares its input, and inc which increments its input by one. Try to use the minimum number of "basic boxes" from above.
  2. Define a "box" that evaluates a polynomial p of the form a*x*x + b*x + c; all four of these are inputs. How many "basic boxes" do you need?
  3. If you could get the polynomial in a different form, could you get away with three "basic boxes"? Why or why not?

Problem 2: Exploring Unix

This problem asks you to figure out what a (somewhat complicated) Unix command does, so you'll need access to a Unix system. One of the first commands to type after you're logged in is man man which will explain how to find and read documentation. Here's the command you need to figure out:

  ls -la / | grep ^d | wc -l

It's important to understand that this command consists of three separate commands connected by what's called a "pipe" in Unix (the vertical bar). The ls command produces some kind of output which is then fed into the grep command; that command does it's job and again produces output which is then fed into the wc command; that command produces output, and this time you get to see it since it is not redirected into another pipe.

Give a brief account of what each of the three commands does, as well as a summary of what the overall effect of the compound command is.

Hints

Problem 3: Multiplication

In lecture we discussed in some detail how to add two binary numbers in twos-complement representation. For this problem you need to give a description of how to multiply two numbers in twos-complement representation. The level of detail should be similar to what we did in lecture. You can use the "standard" method for doing multiplication of decimal numbers with suitable adaptation to binary numbers. Note that multiplication can involve addition as a step, but the number of additions should be given by the length of the binary numbers, not by the value they represent. Try to be as exact as possible, try to not forget a step anywhere.

You should include an example as well, but the process you describe should be generic and work for any two binary numbers.

Problem 4: And you?

Finally, please summarize briefly why you are taking this course and what topics (or kinds of topics) would be of interest to you. Thanks! :-)

Deliverables

Please turn in a simple Unix text file (not M$ Word, not PDF, just plain ASCII text) with your answers. It should be formatted in a decent way of course, and it should contain your contact information. The file name should be cs102-assignment-1-login with login replaced by your Unix login name (so I would use cs102-assignment-1-phf).

Bonus Problem

If you really want to impress us, try the following. From the IRS website: "Filing Late and/or Paying Late: Information You Should Know" What exactly is the meaning of the connective "and/or"? Do you think that using "and/or" is good writing style? Is it logical? Note that we won't give you extra points for this, but we'll give you extra kudos. :-)