MCS-177, Intro. to Computer Science I, Fall 2002 
Homework Assignments


Chapter 8
  1. Do exercise 8.4 on page 220
  2. Do exercise 8.6 on page 220
  3. Do exercise 8.7 on page 220
  4. Do exercises 8.14 on page 225
  5. Do exercises 8.17 on page 229

Chapter 7
  1. Do exercise 7.7 on page 174
  2. Do exercise 7.13 on page 179
  3. Do exercise 7.41 on page 205
  4. Do exercise 7.44 on pages205-206
  5. Do exercise 7.49 on page 208

Chapter 6
  1. Do exercise 6.4 on page 146
  2. Do exercise 6.7 on page 147
  3. Do exercise 6.22 on pages 161-162
  4. Do exercise 6.24 on pages 162-163
  5. Do exercise 6.26 on pages 163-164

Chapter 5
  1. Do exercise 5.17 on pagew 123-124
  2. Do exercise 5.5 on page 113
  3. Do exercise 5.22 on page 126
  4. Do exercise 5.16 on page 123
  5. Do exercise 5.23 on pages 126-127
Chapter 4 Make-up problems
  1. (10 points) Use induction to prove that the version of mod-expt on page 93 of the text does at most e multiplications when e > 0. Note that the code actually does much better than this.
  2. (15 points) Do exercise 4.18 on page 104. Part a is worth 8 points, point b is worth 7 points.
Chapter 4
  1. Do exercise 4.2, parts a.2 and b, on page 92.
  2. Do exercise 4.4 on page 94.
  3. Do exercise 4.11 on pages 99-100.
  4. Do exercise 4.14 on pages 101-102.
  5. Do exercise 4.17 on pages 103-104.

Chapter 3
  1. Using the digit procedures from September 13, write an iterative procedure that counts the number of odd digits in a number. Be sure to include the invariant.
  2. Do exercise 3.4 on page 57.
  3. Do exercise 3.14 on page 70.
  4. Do exercise 3.15 on page 70.
  5. Do exercise 3.19 on page 72.

Chapter 2
  1. Do exercise 2.8 on page 38.
  2. Do exercise 2.11 on page 39.
  3. Do exercise 2.17 on page 44.
  4. Do exercise 2.18 on page 44.
  5. Do exercise 2.20 on pages 44-45.

Chapter 1
  1. Do exercise 1.5 on page 13.
  2. Do exercise 1.12 on page 18.
  3. 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.
  4. Write a Scheme procedure that will find the largest of three integers.  What are some good test values for this procedure?
  5. 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.
    1. Write the Scheme expression to find the middle number of 17 and 5,678,200.
    2. Write a Scheme expression, called middle, that finds the middle number of any two numbers.
    3. What does the following procedure do?  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