Docsity

Exam 2 Solutions - Constructing Proofs | CS 1050, Exams of Computer Science

Toggle sidebar
bg1
Test 3 – Solutions
1. For n= 1, the statement reduces to 1 = 1222
4which is true.
Now, assume that it is true for some natural number n, i.e.
n
X
i=1
i3=n2(n+ 1)2
4.
Add (n+ 1)3to both sides to get
n+1
X
i=1
i3=n2(n+ 1)2
4+ (n+ 1)3.
Now, notice that
n2(n+ 1)2
4+ (n+ 1)3= (n+ 1)2n2+ 4n+ 4
4=(n+ 1)2(n+ 2)2
4.
2
2. This problem (unintentionally) got trickier than I planned, so we tried to
be very gentle when grading your solutions :)
First, we find the general solution of the homogenous equation. The
characteristic equation is x2−2x+1 and it has just one root, 1. There-
fore, the general solution is an=c+dn.
Then, we find a special solution of the nonhomogenous equation. Here,
quadratic polynomials won’t suffice – we have to look for one that is a
cubic polynomial. So, substitute an=An3+Bn2+Cn +Dinto the
recurrence relation. Result:
An3+Bn2+C n +D= 2A(n−1)3+ 2B(n−1)2+ 2C(n−1) + 2D
−A(n−2)3−B(n−2)2−C(n−2) −D+n.
The rest is simple algebra (expand and put together terms with the
same power of n):
A(6n−6) + 2B=n.
Thus, we have two equations for Aand B: 6A= 1, −6A+ 2B= 0,
which give A=1
6and B=1
2.Cand Dcan be anything, for example
0. To sum up, a solution of the nonhomogenous recurrence is
an=n3
6+n2
2.
Now, we look for solution of the nonhomogenous relation with initial
conditions, of the form [solution of nonhomogenous relation]+[general
solution of homogenous relation]; in this case, of the form
an=n3
6+n2
2+c+dn.
We have a0=c= 0 and a1=1
6+1
2+d= 0, i.e. d=−2
3.
Answer: an=n3
6+n2
2−2
3n.2
1
pf2

Partial preview of the text

Download Exam 2 Solutions - Constructing Proofs | CS 1050 and more Exams Computer Science in PDF only on Docsity!

Test 3 – Solutions

  1. For n = 1, the statement reduces to 1 = 1 222 4 which is true. Now, assume that it is true for some natural number n, i.e. ∑^ n

i=

i^3 =

n^2 (n + 1)^2 4

Add (n + 1)^3 to both sides to get n∑+

i=

i^3 =

n^2 (n + 1)^2 4

  • (n + 1)^3.

Now, notice that n^2 (n + 1)^2 4

  • (n + 1)^3 = (n + 1)^2 n^2 + 4n + 4 4

(n + 1)^2 (n + 2)^2 4

  1. This problem (unintentionally) got trickier than I planned, so we tried to be very gentle when grading your solutions :) First, we find the general solution of the homogenous equation. The characteristic equation is x^2 − 2 x+1 and it has just one root, 1. There- fore, the general solution is an = c + dn. Then, we find a special solution of the nonhomogenous equation. Here, quadratic polynomials won’t suffice – we have to look for one that is a cubic polynomial. So, substitute an = An^3 + Bn^2 + Cn + D into the recurrence relation. Result: An^3 + Bn^2 + Cn + D = 2A(n − 1)^3 + 2B(n − 1)^2 + 2C(n − 1) + 2D −A(n − 2)^3 − B(n − 2)^2 − C(n − 2) − D + n. The rest is simple algebra (expand and put together terms with the same power of n): A(6n − 6) + 2B = n. Thus, we have two equations for A and B: 6A = 1, − 6 A + 2B = 0, which give A = 16 and B = 12. C and D can be anything, for example
    1. To sum up, a solution of the nonhomogenous recurrence is

an =

n^3 6

n^2 2

Now, we look for solution of the nonhomogenous relation with initial conditions, of the form [solution of nonhomogenous relation]+[general solution of homogenous relation]; in this case, of the form

an = n^3 6

n^2 2

  • c + dn.

We have a 0 = c = 0 and a 1 = 16 + 12 + d = 0, i.e. d = − 23. Answer: an = n 3 6 +^

n^2 2 −^

2 3 n.^2

1

  1. A quick look at the Venn diagram shows that if Am is the set of numbers in { 1 , 2 ,... , n} divisible by m then the number we are after is | A 3 | + | A 5 | + | A 7 | − 2 | A 3 ∩ A 5 | − 2 | A 3 ∩ A 7 | − 2 | A 5 ∩ A 7 | +3 | A 3 ∩ A 5 ∩ A 7 |= b n 3 c + b n 5 c + b n 7 c − 2 b 15 n c − 2 b 21 n c − 2 b 35 n c + 3b 105 n c.

Here, we are using the fact (widely used in class) that Am has b (^) mn c elements and Am ∩ Ak = Amk.

  1. We have 3 ’r’, 2 ’e’ and ’a’ and 1 ’n’ and ’g’ to choose from. We consider a number of cases, each one assumes how many repeated letters are within the chosen 4:

(i) No repetitions; basically, this means that we select 4 letters out of {’r’,’e’,’a’,’n’,’g’}. This can be done in

( 5 4

) = 5 ways.

(ii) One letter appears twice and no other repetitions. The one which appears twice can be chosen in 3 ways (it has to be ’r’,’e’ or ’a’). The other two can be chosen out of the remaining 4 letters; total number of ways: 3

( 4 2

) = 18.

(iii) Two letters that appear twice. Both have to be chosen out of {’r’,’e’,’a’}. Number of possibilities:

( 3 2

) = 3.

(iv) One letter appears three times. That letter has to be ’r’. The other one can be chosen in 4 ways (it’s ’e’,’a’,’n’ or ’g’).

The answer: 5 + 18 + 3 + 4 = 30.

  1. For a, b ∈ { 0 , 1 }, define

Pab = {(x, y) | x ≡ a (mod 2) and y ≡ b (mod 2)}.

Thus, P 00 is the set of points with even coordinates, P 11 is the set of points with odd coordinates, P 01 - the set of points with even x- coordinate and odd y-coordinate and P 10 - the set of points with odd x-coordinate and even y-coordinate. Notice that if p 1 = (x 1 , y 1 ), p 2 = (x 2 , y 2 ) are in the same set Pab for some a, b ∈ { 0 , 1 } then x 1 + x 2 ≡ a+a ≡ 2 a ≡ 0 and y 1 +y 2 ≡ b+b ≡ 2 b ≡ 0 (modulo 2), i.e. x 1 +x 2 and y 1 + y 2 are both even and therefore the midpoint between the points p 1 and p 2 has integer coordinates. Now, assuming that we have 5 points, by the Pigeonhole principle there have to be two that are in the same set Pab (since there are only 4 sets of this kind). By the first paragraph, the midpoint between the two has integer coordinates. 2