MCS177, Intro. to Computer Science I, Fall 2002
Homework Assignments
Chapter 8
 Do exercise 8.4 on page 220
 Do exercise 8.6 on page 220
 Do exercise 8.7 on page 220
 Do exercises 8.14 on page 225
 Do exercises 8.17 on page 229
Chapter 7
 Do exercise 7.7 on page 174
 Do exercise 7.13 on page 179
 Do exercise 7.41 on page 205
 Do exercise 7.44 on pages205206
 Do exercise 7.49 on page 208
Chapter 6
 Do exercise 6.4 on page 146
 Do exercise 6.7 on page 147
 Do exercise 6.22 on pages 161162
 Do exercise 6.24 on pages 162163
 Do exercise 6.26 on pages 163164
Chapter 5
 Do exercise 5.17 on pagew 123124
 Do exercise 5.5 on page 113
 Do exercise 5.22 on page 126
 Do exercise 5.16 on page 123
 Do exercise 5.23 on pages 126127
Chapter 4 Makeup problems
 (10 points)
Use induction to prove that the version of modexpt on page 93
of the text does at most e multiplications when e > 0. Note
that the code actually does much better than this.
 (15 points)
Do exercise 4.18 on page 104. Part a is worth 8 points, point b is
worth 7 points.
Chapter 4

Do exercise 4.2, parts a.2 and b, on page 92.

Do exercise 4.4 on page 94.

Do exercise 4.11 on pages 99100.

Do exercise 4.14 on pages 101102.

Do exercise 4.17 on pages 103104.
Chapter 3

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.

Do exercise 3.4 on page 57.

Do exercise 3.14 on page 70.

Do exercise 3.15 on page 70.

Do exercise 3.19 on page 72.
Chapter 2

Do exercise 2.8 on page 38.

Do exercise 2.11 on page 39.

Do exercise 2.17 on page 44.

Do exercise 2.18 on page 44.

Do exercise 2.20 on pages 4445.
Chapter 1

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 firstgraders 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 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