MCS-177, Intro. to Computer Science I, Fall 2002
Prep Problems, Chapters 1 - 3
MCS 177 homepage
Schedule
for Sept. 4 - Oct. 18
For each assignment, prepare written answers to the questions and hand
them in at the beginning of class. If you have questions about the
reading, write them down on a 3x5 card and put it on the desk.
-
[ Sept. 9, Section 2.1] Do Exercise 2.1, page 28.
-
[Sept. 11, Section 2.2] Do Exercise 2.4, page 33.
-
[Sept. 13, Section 2.3] Nothing is due. In class, we will be doing
problems like 2.9, 2.10 and 2.11 on page 39.
-
[Sept. 16, Section 3.1] Look at the procedure sum-of-first that appears
on page 36 of the text. Here is another version of it that generates
iterative processes.
(define sum-iter
(lambda (a n); computes a + sum of first n positive integers
(if (= n 0)
a
(sum-iter (+ a n) (-
n 1)))))
(define sum-of-first
(lambda (n) (sum-iter 0 n)))
Illustrate how each version (the recursive on in the text and this
one) is evaluated when called on 4. In other words, show the steps
(as is done on page 26 for (factorial 3) and on page 52 for (factorial
6)) that are needed to evaluate each version of (sum-of-first
4).
-
[Sept. 18, Section 3.2] What is the invariant for the procedure sum-iter
given above? Use induction to prove that sum-iter works.
Last updated: September 10, 2002