Question text is in black, solutions in blue.
Q1: 15 points Q2: 25 points Q3: 30 points plus 5 extra credit Q4: 30 points Total: 100 points plus 5 extra credit
Write an equation for T(n+1) in terms of T(n), and use this equation to prove by (ordinary) induction that for any natural n, T(n) = n(n+1)(n+2)/6.
T(0) = 0, and T(n+1) = T(n) + (n+1)(n+2)/2 since the "k" in the triangle
of cannonballs added is n+1. Let P(n) be the statement "T(n) =
n(n+1)(n+2)/6".
Base Case: P(0) says that T(0) = 0(0+1)(0+2)/6 = 0,
which is true according to the definition.
Inductive step: Assume that P(n) is true. We are given that
T(n+1) = T(n) + (n+1)(n+2)/2, so the IH tells us that T(n+1) =
n(n+1)(n+2)/6 + (n+1)(n+2)/2. By arithmetic, this is equal to
(n+1)(n+2)[n/6 + 1/2] = (n+1)(n+2)[(n+3)/6] which is what T(n+1) is supposed
to be according to P(n+1). We have completed the inductive step and thus the
proof.
The following pseudo-Java method is intended to compute Z(n):
public natural zcode (natural n)
{// Returns Z(n) as defined above
if (n <= 1) return n;
return 2 * zcode (n/2);}
This question have three parts, all of which refer to the function Z:
By successive substitution into the definition, Z(13) = 2 times Z(6) = 4 times Z(3) = 8 times Z(1) = 8.
zcode
does in fact
compute Z(n) as defined. (Hint: Use strong induction on n, with two
base cases.)
Let P(n) be the statement " First Base Case: If n=0, Z(0) is defined to be 0, and the method
returns 0 with no recursion.
Second Base Case: If n=1, Z(1) is defined to be 1, and the method
returns 1 with no recursion.
Strong Inductive Step: Let n ≥ 1 and
assume P(i) for all i with i ≤ n. P(n+1)
says that the method terminates on input n+1, with output Z(n+1). Z(n+1) is
defined to be 2 times Z((n+1)/2), since n+1 > 1. On input n+1, the code
recursively calls zcode
terminates on input n and
returns Z(n)".
zcode((n+1)/2)
. Since (n+1)/2 ≤ n (see the
fall 2004 exam solutions for a proof), the strong IH tells us that P((n+1)/2)
is true and thus that the recursive call terminates and returns a value of
Z((n+1)/2). The original method takes this value, doubles it, and returns it,
thus returning the value 2 times Z((n+1)/2) or Z(n+1). We have proved P(n+1),
so we have completed the inductive step and thus the proof.
Prove by (strong) induction on all positive naturals n that Z(n) is a power of two, where Z is the function defined above. (Make sure that you use the appropriate base case for positive naturals.)
Let Q(n) be the statement "Z(n) is a power of two". We prove Q(n) by strong
induction on positive naturals:
Base Case: For n=1, Z(n) = 1 by definition of Z, and 1 is defined
to be a power of two, so P(1) is true.
Strong Inductive Case: Assume that P(i) is true for all i with
i ≤ n. Z(n+1) is defined to be 2 times Z((n+1)/2). Since (n+1)/2 ≤ n,
P((n+1)/2) is true as port of the strong IH, so we know that Z((n+1)/2) is
a power of two. Since Z(n+1) is twice a power of two, by the definition it is
also a power of two and P(n+1) is true. We have completed the strong induction
and thus the proof.
22 = 2 times 11, 27 = 3 times 3 times 3, greatest common divisor = 1 since no prime occurs in both factorizations, least common multiple = 22 times 27 = 594 since it is (22 times 27) divides by the gcd.
Inverse algorithm:
So we let a be 9 and let b be -11.
Since 9 times 27 is shown above to be 1 plus a multiple of 22, we have that 9(27) ≡ 1 (mod 22). Thus 9 is an inverse of 27, modulo 22. Any integer of the form 9 = 22k, where k is an integer, is also an inverse, so the naturals 9, 31, 53, 74, ..., are all correct answers to this question.
By reasoning similar to that in (d), we see that -11 is an inverse of 22, modulo 27. Thus -11(22) ≡ 1 (mod 27), and clearly -11(22) ≡ 0 (mod 22). But our answer must be a natural. We can add 27(22) = 594 to the answer and still have it satisfy both congruences (since the Chinese Remainder Theorem says that they are equivalent to a single congruence mod 594). This gives us (-11+27)(22) = 16(22) = 352. To check, 352 = 13(27) + 1.
The standard way to solve this problem from the proof of the Chinese
Remainder Theorem is as follows: (20)(9)(27) + (15)(-11)(22) is congruent
to (20)(9)(27) ≡ 20 (mod 22) because 9 is the inverse of 27 modulo 22,
and the same number is congruent to (15)(-11)(22) ≡ 15 (mod 27),
because -11 is the inverse of 22 modulo 27. This gives 4860 - 3630 = 1230.
In this particular case it is easier to look for small solutions. The
naturals that are congruent to 15 modulo 27 are 15, 42, 69, 96, 123,..., and
the naturals that are congruent to 20 modulo 22 are 20, 42, 64, 86, 108,
130,..., so if we notice that 42 (the answer to life, the universe, and
everything) is on both lists we have our solution.
Of course both answers can be correct since they are congruent modulo 594.
For the base case, any string in Σ*b is equal to wb for some string b, so it is in X by Rule 2. For the inductive step, let w be an arbitrary string and assume that w is in X. Then by Rule 3, wa is in Y. By Rule 4, waa is in X. We have proved P(w) → P(waa) and completed the induction.
Base Case: By Rule 1, λ∈ X, so λ∈ X∪Y and
Q(λ) is true.
First Inductive Step: Assume w ∈ X∪Y. If w ∈ X, then
by Rule 3, wa ∈ Y so wa ∈ X∪Y and Q(wa) is true. If w ∈
Y, then by Rule 4, wa ∈ X so wa ∈ X∪Y and Q(wa) is true. Since
the IH says that either w∈X or w∈Y, the IH implies Q(wa).
Second Inductive Step: For any string w,
by Rule 2, wb ∈ X and thus wa ∈
X∪Y and Q(wb) is true. So the implication Q(w) → Q(wb) is true by
the rule of Trivial Proof.
Since the base case and both inductive steps are proved, by string
induction Q(w) is proved for any string w in Σ*.
Last modified 1 April 2005