CS124, Fall 2010
Assignment #1
DUE: Thursday, Sept. 9.
Problems in (or, in one case,
inspired by) Schneider and Gersting:
- Chapter 2, exercises 3 and 8.
- Inspired by Chapter 1, exercise 9 (let's call it
"exercise 9a"): One way to do division is by repeated
subtraction. For example, 1175 ÷ 47 can be be
determined by counting many times 47 must appear in
the expression 1175 - 47 - 47 - 47 …, where
we keep subtracting as long as we get something that's
at least 0. Sketch out
an algorithm for dividing a by b
using this technique. (In the example given, the expression
1175 ÷ 47 gives the quotient 25, with no remainder. I'll
only ask for the integer quotient here, e.g., 23 ÷ 4
should give 5. But if you compute the quotient by repeated
subtraction, it shouldn't be hard to figure out the
remainder as well.)
- Chapter 1, "Challenge Work" 1
Hand in:
-
Clearly written pseudocode in the style of Chapter 2
for all problems.
Back to CS
124 Home Page