Download HW 7 solutions

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Positional notation wikipedia , lookup

Georg Cantor's first set theory article wikipedia , lookup

Addition wikipedia , lookup

Mathematical proof wikipedia , lookup

Mathematics of radio engineering wikipedia , lookup

Fundamental theorem of algebra wikipedia , lookup

Recurrence relation wikipedia , lookup

Line (geometry) wikipedia , lookup

Strähle construction wikipedia , lookup

Elementary mathematics wikipedia , lookup

Proofs of Fermat's little theorem wikipedia , lookup

Transcript
CS 173: Discrete Structures, Spring 2011
Homework 7 Solutions
This homework contains 4 problems worth 38 problems.
1. (10 points) Consider the inequality 2n > n2 + n.
(a) (2 points) What is the smallest positive integer value of n for which this inequality
holds?
Solution: The smallest positive integer value for which the inequality holds is 5.
(b) (8 points) Prove that this inequality holds for integers n greater than or equal to
your lower bound from part (a).
Solution:
Claim: The inequality 2n > n2 + n holds true for all n ≥ 5.
Proof. We will use induction on n.
Base Case: The base case occurs when n = 5 and we have 25 = 32 > 30 = 52 + 5
Inductive Step: Suppose 2i > i2 + i for all i ∈ [5, k], where i, k ∈ Z and k ≥ 5. We
need to prove that the claim holds for n = k + 1, i.e. 2k+1 > (k + 1)2 + (k + 1).
2k+1 =
>
=
≥
=
2 × 2k
2 × (k 2 + k)
k 2 + 2k + k 2
k 2 + 2k + k + 2
(k + 1)2 + (k + 1)
The first inequality results from our inductive hypothesis. The second inequality holds
true since we know that k ≥ 5 and therefore we have k 2 > k + 1. Thus, the claim holds
for n = k + 1. Hence, it follows from induction that 2n > n2 + n for all n ≥ 5.
2. (8 points) Prove that consecutive Fibonacci numbers are relatively prime.
Solution:
Proof. Let the ith Fibonacci number be denoted by Fi . We will prove the claim using
induction on n.
Base case: The first two consecutive Fibonacci numbers are F0 and F1 . So the base
case is n = 0.
F0 = 0 and F1 = 1. So gcd(F0 , F1 ) = gcd(0, 1) = 1. So they are relatively prime.
1
Inductive step: Assuming that consecutive Fibonacci numbers Fk−1 and Fk (where
k ≥ 1) are relatively prime. We need to prove that Fk and Fk+1 are relatively prime.
gcd(Fk+1 , Fk ) =
=
=
=
gcd(Fk , remainder(Fk+1 , Fk ))
gcd(Fk , remainder(Fk−1 + Fk , Fk )
gcd(Fk , Fk−1 )
1
The first equality holds by a property of GCD that we proved while discussing the
Euclidean algorithm. The second equality holds by definition of Fibonacci numbers.
For the third step, observe that Fk−1 < Fk , which implies that the remainder of Fk−1
divided by Fk is Fk−1 . The last equality holds by the inductive hypothesis. Thus, Fk
and Fk+1 are relatively prime, so our claim holds for n = k.
Therefore, the statement that consecutive Fibonacci numbers are relatively prime holds
for n ≥ 0.
Alternate approach: An alternative approach for the inductive step is to use some
version of proof by contradiction or contrapositive. For example:
Suppose that Fk and Fk+1 had some common factor d > 1. By the definition of the
Fibonacci numbers, Fk+1 = Fk + Fk−1 . So Fk−1 = Fk+1 − Fk . So, since d divides both
Fk and Fk+1 , it must also divide Fk−1 . (See facts about divisibility proved in lecture.)
But this means that d is a common factor (> 1) of Fk and Fk−1 , so they cannot be
relatively prime, contradicting our inductive hypothesis.
Assuming a common factor for Fk and Fk+1 led to a contradiction, so they must be
relatively prime.
3. (10 points) Define a =
√
1+ 5
,
2
b=
√
1− 5
2
and let F(n) be the nth Fibonacci number.
(a) (2 points) Show that a2 = a + 1 and b2 = b + 1
Solution:
√ 2
√
5
1
+
1
2
a =
1+2× 5+5 =
=
2
4
√ 1+ 5
+1=a+1
=
2
√ 2
√
5
1
1
−
2
1−2× 5+5 =
=
b =
2
4
√ 1− 5
+1=b+1
=
2
2
√
1
6+2× 5
4
√
1
6−2× 5
4
(b) (8 points) Using strong induction and the result of part (a) prove that F (n) =
an −bn
.
a−b
Solution:
Proof. We prove the claim using induction on n.
Base Case: The base case here occurs for n = 0.
a0 − b0
1−1
=
= 0 = F0
a−b
a−b
We also need a second base case for n = 1
a−b
a1 − b1
=
= 1 = F1
a−b
a−b
i
i
−b
Inductive Step: Assuming that the equality Fi = aa−b
holds true for all i ∈ [0, k],
ak+1 −bk+1
where k ≥ 1, we need to prove that Fk+1 =
.
a−b
Fk+1 = Fk−1 + Fk
k
k−1
a − bk
a
− bk−1
+
=
a−b
a−b
k−1
k−1
k
k
a
−b
+a −b
=
a−b
k−1
a (a + 1) − bk−1 (b + 1)
=
=
ak+1 − bk+1
a−b
The first equality holds by definition of Fibonacci numbers. The second uses the
inductive hypothesis. The fourth inequality holds because we have proved in part (a)
that a2 = a + 1 and b2 = b + 1. So the equation holds true for n = k + 1.
Therefore, the equality F (n) =
an −bn
a−b
holds for all n ≥ 1.
4. (10 points) A bitstring is simply a finite sequence of zeroes and ones. For the purposes
of this problem, strings will always have length ≥ 1, i.e. no zero-length strings.
Let’s define Sn to be the set of all bit strings of length n that contain no consecutive
zeroes. For example, 01 is a member of S2 and 010110 is a member of S6 . Strings like
01100, 001, 1000 are not in any Sn because they have two or more zeros in a row.
Define Tn = |Sn |, i.e. Tn is the number of bitstrings of length n that contain no
consecutive zeroes.
3
(a) Give the value of Tn for values of n between 1 and 5.
Solution: S1 = {0, 1} and T1 = 2
S2 = {01, 11, 10} and T2 = 3
S3 = {010, 011, 110, 111, 101} and T3 = 5
S4 = {0101, 0110, 0111, 1101, 1110, 1111, 1010, 1011} and T4 = 8
S5 = {01010, 01011, 01101, 01110, 01111, 11010, 11011, 11101, 11110, 11111,
10101, 10110, 10111} and T5 = 13
(b) Give a recursive definition for Tn . Include one or more appropriate base cases..
Briefly explain your answer.
Solution: The sequence above should look familiar, and we can guess at this
point of time that Ti = Fi+2 where Fi is the ith Fibonacci number. Hence, the
recurrence relation here is Tn = Tn−1 + Tn−2 for all n ≥ 3. The base cases (aka
initial conditions) are that T1 = 2 and T2 = 3.
An intuitive way to think about this recurrence, without pure guessing, is to focus
on the last bit of a valid string of length n, where “valid” means that the string
contains no consecutive zeroes. There are two mutually exclusive cases, depending
on whether the last bit in the string is 0 or 1.
If the last (nth ) bit of a valid string of length n is 0, then we know that the (n−1)th
bit must be 1 (otherwise the condition would be violated). The first n − 2 bits of
the string must not contain any consecutive zeros, but that’s the only constraint
on them. So, number of possible valid strings of length n bits that end with 0 is
exactly equal to number of valid strings with length n − 2 bits.
Now consider the case where a valid string of length n ends with 1 i.e. the nth bit
is 1. The first n − 1 bits of such a string could be any combination of 0s and 1s
as long as this earlier part of the string is valid. So, the number of valid strings
of length n bits that end with 1 is exactly equal to number of valid strings with
length n − 1 bits.
So the first case gives us T (n−2) possibilities and the second case gives us T (n−1)
possibilities. Adding them together gives us the above recurrence for T (n).
4