Tải bản đầy đủ (.pdf) (5 trang)

bài tập cấu trúc rời rạc homework6 solutions

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (129.86 KB, 5 trang )

COM S 330 — Homework 06 — Solutions
Type your answers to the following questions and submit a PDF file to Blackboard. One page per problem.
Problem 1. [10pts] Consider the following sequence definitions. Write out the first 10 terms (n ∈ {0, . . . , 9})
of each sequence.
a. [3pts] a0 = 2 and an = 2an−1 − 1 for n ≥ 1.
n 0

1

2

3

4

5

6

7

8

9

an

2

3


5

9

17

35

69

137

273

545

b. [3pts] b0 = 0 and bn = bn−1 +

1
2n

for n ≥ 1.

n 0

1

2

3


4

5

6

7

8

9

0

1
2

3
4

7
8

15
16

31
32


63
64

127
128

255
256

511
512

bn

c. [4pts] c0 = 1, c1 = 2, and cn = 2(cn−1 − cn−2 ) for n ≥ 2.
n

0

1

2

3

cn

1

2


2

0 −4

4

1

5

6

7

8

9

−8

−8

0

16

32



COM S 330 — Homework 06 — Solutions
Problem 2. [5pts] Let {dn }∞
n=0 be a sequence with the recurrence relation dn = 2dn−1 −dn−2 for n ≥ 2. (We
do not specify the terms d0 , d1 .) Use backward reasoning to motivate the closed form dn = nd1 − (n − 1)d0 .
We will apply the recurrence relation several times to deduce a pattern.

dn = 2dn−1 − dn−2
= 2(2dn−2 − dn−3 ) − dn−2
= (4 − 1)dn−2 − 2dn−3
= 3dn−2 − 2dn−3
= 3(2dn−3 − dn−4 ) − 2dn−3
= (6 − 2)dn−3 − 3dn−4
= 4dn−3 − 3dn−4
= 4(2dn−4 − dn−5 ) − 3dn−4
= 5dn−4 − 4dn−5
..
.
= kdn−(k−1) − (k − 1)dn−k
..
.

For k ≥ 1.

= ndn−(n−1) − (n − 1)dn−n = nd1 − (n − 1)d0 .

2


COM S 330 — Homework 06 — Solutions
Problem 3. [10pts] Mathematical induction can be used to prove things that can be proven directly. In

the two problems below, you will essentially prove the induction step of an induction proof.
a. [5pts] For n ≥ 0, let P (n) denote the sentence “The 2 × n chessboard can be tiled using dominoes.” Prove
“P (n) → P (n + 1).”
Proof. Let C be the 2 × (n + 1) chessboard. Place a domino vertically on the far-right edge, leaving a 2 × n
chessboard of open squares. Since the 2 × n chessboard can be tiled using dominoes, that tiling can complete
the tiling of C. Therefore, the 2 × (n + 1) chessboard can be tiled using dominoes.
b. [5pts] For n ≥ 0, let Q(n) denote the sentence “The 3 × 2n chessboard can be tiled using dominoes.”
Prove “Q(n) → Q(n + 1).”
Proof. Let C be the 3 × 2(n + 1) chessboard. Place two dominoes vertically in the top-right corner, one tile
covering the positions (1, 2n + 2), (2, 2n + 2) and the other covering positions (1, 2n + 1), (2, 2n + 1). Then
place a domino horizontally in the bottom-right corner, covering the positions (3, 2n + 2), (3, 2n + 1). The
remaining squares form a 3 × 2n chessboard. Since the 3 × 2n chessboard can be tiled using dominoes, this
tiling completes the tiling of C. Therefore, the 3 × 2(n + 1) chessboard can be tiled using dominoes.

3


COM S 330 — Homework 06 — Solutions
Problem 4. [10pts] Define a sequence {fn }∞
n=0 as f0 = 1 and for n ≥ 1, fn =
fn =

Fn+1
Fn+2 ,

where

{Fn }∞
n=0


1
1+fn−1 .

Prove that for n ≥ 0,

is the Fibonacci sequence.

Proof. We use induction.
Case n = 0: f0 = 1 =

1
1

=

F1
F2 .

(Induction Hypothesis) Assume that fn =

Fn+1
Fn+2

for some n ≥ 0.

Case n + 1: Consider fn+1 .
fn+1 =
=
=
=

=

1
1 + fn
1
1+

Fn+1
Fn+2

By recurrence relation of fn+1
By Induction Hypothesis

1
Fn+1 +Fn+2
Fn+2

1
Fn+3
Fn+2

By recurrence relation Fn+3 = Fn+2 + Fn+1 , since n + 3 ≥ 2.

Fn+2
.
Fn+3

Therefore, by induction we have that fn =

Fn+1

Fn+2

for all n ≥ 0.

4


COM S 330 — Homework 06 — Solutions
Problem 5. [10pts] Let {An }1
n=1 be an arbitrary sequence of non-empty sets. Recall the n-fold Cartesian
n
product i=1 Ai is the set of n-tuples (a1 , . . . , an ) where each ai is an element in Ai . The iterated product is
the set sequence {Bn }1
n=1 where B1 = A1 , and for n ≥ 2, Bn = Bn 1 × An . (Thus, B1 = A1 , B2 = A1 × A2 ,
B3 = (A1 × A2 ) × A3 , etc.) Use induction to prove that for all n ≥ 2, there is a bijection fn from n-fold
n
Cartesian product i=1 Ai to the iterated product Bn = Bn 1 × An . [Note: the n-fold Cartesian product
n
i=1 Ai consists of n-tuples (a1 , . . . , an ), while the iterated product Bn consists of ordered pairs (b, an )
where b ∈ Bn 1 and an ∈ An .]
Proof. We use induction on n ≥ 1.
Case n = 1: Note that A1 = B1 , so the identity map f1 : A1 → B1 defined as f1 (x) = x is a bijection
between A1 and B1 .
(Induction Hypothesis) Assume that for some n ≥ 1 we have a bijection fn :

n
i=1

Ai → B n .
n


Case n + 1: Note that by the Induction Hypothesis there exists a bijection fn : i=1 Ai → Bn . We den+1
fine a function fn+1 : i=1 Ai → Bn+1 as follows: For an arbitrary (n + 1)-tuple (x1 , . . . , xn , xn+1 ) in
n+1
i=1 Ai , let fn+1 (x1 , . . . , xn , xn+1 ) = (fn (x1 , . . . , xn ), xn+1 ). We claim that fn+1 is a bijection. First, since
n
fn (x1 , . . . , xn ) ∈ Bn for all (x1 , . . . , xn ) ∈ i=1 Ai (by Induction Hypothesis), we have that (fn (x1 , . . . , xn ), xn+1 )
n+1
is an element of Bn × An+1 for every (x1 , . . . , xn+1 ) ∈ i=1 Ai . Therefore, fn+1 is a well-defined function
with codomain Bn+1 = Bn × An+1 .
n+1

We claim fn+1 is an injection: Let (x1 , . . . , xn , xn+1 ) and (y1 , . . . , yn , yn+1 ) be elements of i=1 Ai where
fn+1 (x1 , . . . , xn+1 ) = fn+1 (y1 , . . . , yn+1 ). Since the first coordinate in these function outputs are equal, we
have that fn (x1 , . . . , xn ) = fn (y1 , . . . , yn ). Since fn is an injection, we have that (x1 , . . . , xn ) = (y1 , . . . , yn ).
Since the second coordinate in the function outputs are equal, xn+1 = yn+1 . Therefore, fn+1 is an injection.
We claim fn+1 is a surjection: Let (y, z) ∈ Bn × An+1 = Bn+1 be any element of the codomain. Since fn
n
is surjective, there exists an n-tuple (x1 , . . . , xn ) ∈ i=1 Ai where fn (x1 , . . . , xn ) = y. Since z ∈ An+1 , note
that fn+1 (x1 , . . . , xn , z) = (y, z) and therefore (y, z) is in the range of fn+1 and hence fn+1 is surjective.
By induction, there exists a bijection fn :

n
i=1

Ai → Bn for every n ≥ 1.

5




×