MCS-177, Intro. to Computer Science I, Fall 2007
Homework Assignment 1
Due: Monday, Feb. 19
You are encouraged to discuss the homework with your fellow students.
This does not mean that you divide up the problems so that one
student solves a problem and then
tells the others how to do it. Instead, each of you should attempt
the problems on your own, discuss the problems you encounter with
others, brainstorm on ideas for solving these problems, and so on.
Each of you is expected to write up your homework independently. If
you worked closely with other people, say so at the top of your paper.
Each problem is graded on a 10-point scale. Be sure to see the guidelines for writing up homework
assignments.
- Do exercise 1.5 on page 13.
- Do exercise 1.12 on page 18.
- Modify the procedure in exercise 1.12 so that it will return 17
if
either
of its two arguments is even. If both are odd, this modified
procedure
should still return their product.
- Write a Scheme procedure that will find the largest of three
integers.
What are some good test values for this procedure?
- The first-graders I used to work with liked to find the
``middle''
number
of two numbers. For example, the middle number of 3 and 9 is
6,
while the middle number of 1 and 10 is 5.5.
- Write the Scheme
expression to find the middle number of 17 and 5,678,200.
- Write a Scheme expression,
called middle, that finds the middle number of any two numbers.
- What value does the following
procedure compute? Try to describe this as succinctly as you
can.
(define mystery
(lambda (x y z w)
(middle (middle x y)
(middle z w))))
MCS 177 homepage