Docsity

Homework 1 Solutions - Mathematics, Algorithm and Systems Analysis | CSE 21, Assignments of Computer Science

Toggle sidebar
bg1
CSE21 HW #1 Solution
1. (10 Points) Let A(n) be an assertion Fn<(7
4)n, where n≥1, Fn=
Fn−1+Fn−2and F0= 1, F1= 1.
Bass case: we prove the base case, A(1) is true.
F1= 1 <(7
4)1, So the base case is true.
Induction step: assume that A(k) is true, for 1 ≤k≤n−1, Then we prove
A(n) is true.
(Graders, for those who only assume that A(n−1) is true, please take 2 points
off. Because this assumption is not strong enough for proving the general cases.)
Fn=Fn−1+Fn−2<(7
4)n−1+ (7
4)n−2= (7
4+ 1)(7
4)n−2=11
4(7
4)n−2=
44
16 (7
4)n−2<49
16 (7
4)n−2= (7
4)n.
Thus, A(n) is true for n≥1.
2. (10 Points)
1st Step: We solve the roots of the polynomial t2−4t−8 = 0. The two roots
are r1=4+√42−(4×(−8))
2= 2 + 2√3, r2=4−√42−(4×(−8))
2= 2 −2√3.
So the polynomial has two distinct roots.
2nd Step: We compute Cand D.
It follows the distinct-roots theorem that this sequence satisfies the explicit for-
mula
an=C(2 + 2√3)n+D(2 −2√3)n, for all integers n≥0
where Cand Dare the numbers whose values are determined by the fact that
a0= 2 and a1= 2.
Cand Dare solutions to the equations:
C+D= 2
(2 + 2√3)C+ (2 −2√3)D= 2
So C=(6−√3)
6, D =(6+√3)
6and we get the formula for an:
an=(6−√3)
6(2 + 2√3)n+(6+√3)
6(2 −2√3)n, for n≥2.
3.(10 Points)
(a) If there are n−1 lines on the place then there are Pn−1regions defined.
Adding a new line does not delete already existing regions, therefore
Pn=Pn−1+ number of new regions created by the new line
If the n-th line is not parallel to any of the previous n−1 lines then it will
intersect each of them. When we have two lines P2= 4, P3=7=P2+ 3. The
third line intersects the previous two lines in two points and thus creates 3 new
regions. So when we have n−1 lines, the n-th line will add nnew regions. And
1
pf3
pf4

Partial preview of the text

Download Homework 1 Solutions - Mathematics, Algorithm and Systems Analysis | CSE 21 and more Assignments Computer Science in PDF only on Docsity!

CSE21 HW #1 Solution

  1. (10 Points) Let A(n) be an assertion Fn < ( 74 ) n , where n ≥ 1, Fn = Fn− 1 + Fn− 2 and F 0 = 1, F 1 = 1.

Bass case: we prove the base case, A(1) is true.

F 1 = 1 < ( 74 ) 1 , So the base case is true.

Induction step: assume that A(k) is true, for 1 ≤ k ≤ n − 1, Then we prove A(n) is true. (Graders, for those who only assume that A(n − 1) is true, please take 2 points off. Because this assumption is not strong enough for proving the general cases.)

Fn = Fn− 1 + Fn− 2 < ( 74 ) n− 1

  • ( 74 ) n− 2 = ( 74 + 1)( 74 ) n− 2 = 114 ( 74 ) n− 2 = 44 16 (^

7 4 )

n− 2 < 4916 ( 74 ) n− 2 = ( 74 ) n . Thus, A(n) is true for n ≥ 1.

  1. (10 Points) 1st Step: We solve the roots of the polynomial t^2 − 4 t − 8 = 0. The two roots

are r 1 = 4+

42 −(4×(−8)) 2 = 2 + 2

3, r 2 = 4 −

42 −(4×(−8)) 2 = 2^ −^2

So the polynomial has two distinct roots.

2nd Step: We compute C and D. It follows the distinct-roots theorem that this sequence satisfies the explicit for- mula an = C(2 + 2

n

  • D(2 − 2

n , for all integers n ≥ 0 where C and D are the numbers whose values are determined by the fact that a 0 = 2 and a 1 = 2. C and D are solutions to the equations: C + D = 2 (2 + 2

3)C + (2 − 2

3)D = 2

So C = (6−

√

6 , D^ =^

(6+ √

6 and we get the formula for^ an: an = (6−

√

6 (2 + 2

n

  • (6+

√

6 (2^ −^2

n , for n ≥ 2.

3.(10 Points) (a) If there are n − 1 lines on the place then there are Pn− 1 regions defined. Adding a new line does not delete already existing regions, therefore

Pn = Pn− 1 + number of new regions created by the new line

If the n-th line is not parallel to any of the previous n − 1 lines then it will intersect each of them. When we have two lines P 2 = 4, P 3 = 7 = P 2 + 3. The third line intersects the previous two lines in two points and thus creates 3 new regions. So when we have n − 1 lines, the n-th line will add n new regions. And

we have the following recursive formula: Pn = Pn− 1 + n.

(b) We use the method of iteration, and first will compute several terms of the sequence Pn = Pn− 1 + n. P 0 = 1 P 1 = P 0 + 1 = 1 + 1 = 2 P 2 = P 1 + 2 = (2 + 1) + 1 = 4 P 3 = P 2 + 3 = (3 + 2 + 1) + 1 = 7 P 4 = P 3 + 4 = (4 + 3 + 2 + 1) + 1 = 11. So we guess Pn = 1 + the sum of the first n numbers or

Pn = 1 +

∑^ n

i=

i = 1 +

n(n + 1) 2

Next we will prove the guess by induction:

  • Base case: The claim holds for n = 1 P 1 = 1 + 1 = 2
  • Induction step: Suppose the claim holds for some integer n, namely Pn = 1+ n(n 2 +1) We will prove it for n+1. Using the recursive definition and the induction hypothesis we obtain: Pn+1 = Pn + n + 1 = 1 + n(n 2 +1) + n + 1 = 1 + n(n+1)+2( 2 n+1)= 1 + (n+1)( 2 n+2)
  1. (10 Points)

A^2 =

A^3 =

A^4 =

A^5 =

We conjecture that for n ≥ 2, An^ =

Fn Fn− 1 Fn− 1 Fn− 2

, where Fn is the n-th

Fibonacci number. Recall that a recursive definition of the Fibonacci numbers is Fn = Fn− 1 + Fn− 2 , and F 1 = F 0 = 1. We prove the correctness of the general formula using mathematical induction.

  • Base case: n = 2, we have calculated that A^2 =

F 2 F 1

F 1 F 0

  • Induction step: Suppose the claim holds for some integer( n, that is An^ = Fn Fn− 1 Fn− 1 Fn− 2

We prove it for n + 1.

So C = 1, D = 3 and we get the formula for Sn: Sn = 3n^ + 3(−1)n, for all integers n ≥ 4, with the initial conditions of S 2 = 12 and S 3 = 24.

  1. (10 Points) 1st Step: Derive the recurrence relation. We consider two cases: Case 1: The first (leftmost) bit of the n-bit binary number (n ≥ 3) is 0, then the number of such n-bit binary numbers that satisfy the condition is equal to an− 1. Case 2: The first (leftmost) bit of the n-bit binary number (n ≥ 3) is 1, then the second bit from the left can only be 0 (cannot be 1). Therefore, the number of such n-bit binary numbers that satisfy the condition is equal to an− 2. So we have the recurrence relation for an: an = an− 1 + an− 2 for all n ≥ 3. The initial conditions: a 1 = 2 (0 and 1); a 2 = 3 (00, 01 and 10).

Note: You may also use a 0 = 1 (≤); a 1 = 2 ( 0 and 1 ) as the initial conditions.

2nd Step: We solve the roots of the polynomial t^2 − t − 1 = 0. The two roots

are r 1 = 1+

12 −(4×(−1)) 2 =^

1+√ 5 2 ,^ r^2 =^

1 −

12 −(4×(−1)) 2 =^

1 −√ 5

So the polynomial has two distinct roots.

3rd Step: We compute C and D. It follows the distinct-roots theorem that this sequence satisfies the explicit formula an = C( 1+

√ 5 2 )

n

  • D( 1 −

√ 5 2 )

n , for all integers n ≥ 4 where C and D are the numbers whose values are determined by the fact that a 1 = 2 and a 2 = 3. C and D are solutions to the equations: 1+ √ 5 2 C^ +^

1 − √ 5 2 D^ = 2

( 1+

√

2

2 C + ( 1 −

√ 5 2 )

2 D = 3

So C = 5+

√ 5 10 , D^ =^

5 − 3 √ 5 10 and we get the formula for^ Sn: an = 5+

√ 5 10 (^

1+ √ 5 2 )

n

  • 5 −^3

√ 5 10 (^

1 − √ 5 2 )

n , for all integers n ≥ 3, with the initial condition of a 1 = 2 and a 3 = 3.