This assignment is due on Monday, February
28, by 7:00 p.m. in the box in CS 189.
Summary: Here we explore issues surrounding
control structures and subroutines.
Readings and review questions: You
should know the answers to the review questions listed below, but you do
not have to turn them in (except for the questions listed in part (a)
below).
Chapter 7: 1, 4 (the first part only), 5,
8-18, 20
Chapter 8: 1-10, 13-21
Chapter 9: 1-7, 13, 18
(a) Give a very brief answer to review
questions 8, 13, and 17 on page 324 of Sebesta.
(b) Do the following problems from
the problem set (not the review questions) that starts on page 324 of Sebesta:
-
10, for Pascal, C++, Java, and Scheme. You
should be able to use what you know from previous assignments and the examples
in the book; you don't really need to know all those languages. (For
Scheme, use recursion and let
instead of do
and set!.
Don't worry that nothing gets done with the variable i.)
Keep the "discuss" part to about one sentence, but give a good
reason for your conclusion.
-
12, for Pascal, C++, Java, and Scheme. (For
Scheme, you can use cond
or case,
the syntax of which you can find in the on-line help. Again, don't
worry about j
going out of scope and being lost. For extra credit (both here and in problem
10), you can redesign the Scheme code to return the correct value
of i
or j.)
-
13.
-
17 (C and C++ should be interchangeable in
this case).
-
19; two or three clear, concise sentences
should be enough here.
-
(extra credit) 14 and 15, commenting particularly
on how you think Knuth's arguments hold up 25 years later.
(c) Do problems 9 and 10 from the
problem set (not the review questions) that starts on page 375 of Sebesta.
Problem 15 is extra credit.
(d) Do problems 3 and 5 from the problem
set (not the review questions) that starts on page 409 of Sebesta. For
extra credit, do problems 4 and 6.