discrete mathematics: solutions to homework assign- …lisisam/discrete/homework2_solution.pdf ·...
TRANSCRIPT
Discrete Mathematics: Solutions to Homework Assign-ment 2
1. Solve the following linear recurrence :
an+2 = 3an+1 − 2an
subject to the initial conditions a1 = 1 and a2 = 5.
We first consider the recurrence only. We look for solutions of the form an = rn.Then, we obtain the following equation on r:
rn+2 = 3rn+1 − 2rn ∀n ≥ 0
Simplifying, we obtain :r2 = 3r − 2.
By means of the quadratic formula, or by directly factoring, we obtain :
r = 1 or r = 2.
This means the general solution to our recurrence is :
an = A1n + B2n
for some constants A and B. We will now solve for A and B by using our initialconditions (a1 = 1 and a2 = 5).This becomes :
1 = a1 = A + B25 = a2 = A + B4.
From these two equations, we obtain : 2B = 4 so B = 2 and thus A = −3.Putting this all together, we obtain then :
an = −3(1n) + 2(2n) = −3 + 2n+1.
2. Let An be the number of subsets of {1, 2, · · · , n} that contain no three consecutiveintegers.Find a recurrence relation for An (justify your answer).
Let us call the subsets of {1, . . . , n} which satisfy the property of containing no threeconsecutive integers, “good subsets”. We are then interested in relating the number
of “good subsets” of {1, . . . , n} to the number of good subsets of {1 . . . k} for somechoices of k smaller than n.Let us consider the good subsets of {1 . . . n}. We assume n ≥ 3. Any good subset Sof {1 . . . n} satisfies exactly one of the three following properties :
(a) n /∈ S. Then, S ⊂ {1, . . . , n − 1}. The total number of good subsets S thatsatisfy this property is then An−1.
(b) n ∈ S and (n − 1) /∈ S. Then, S = T ∪ {n}, where T is now a good subset of{1, 2, . . . , n − 2}. We then have a correspondance between the good subsets Tof {1, 2, . . . , n− 2} and the good subsets S of {1 . . . , n} satisfying this additionalproperty.Thus, the number of subsets satisfying this property is given by An−2.
(c) n ∈ S and (n− 1) ∈ S. Since these are both in S, (n− 2) /∈ S. So, we may write: S = T ∪ {n− 1, n− 2}, where T is a good subset of {1, . . . , n− 3}.We then obtain that the number of good subsets satisfying this property is givenby An−3.
From this, we obtain that the total number of good subsets of {1, 2, . . . , n}, is givenby the sum of the number of good subsets satisfying each of these three properties.This gives us :
An = An−3 + An−2 + An−1, for n ≥ 4.
This establishes the recurrence relation we desired. We now need to find, by directcounting, the numbers A0, A1 and A2, since these are not prescribed by the recurrence.We obtain :A0 = 1, A1 = 2, A2 = 4 and A3 = 7.
3. Let Fn denote the n’th Fibonacci number, given by the recurrence Fn+2 = Fn + Fn+1
and initial conditions F0 = 1, F1 = 1.Show that F5n−1 is a multiple of 5 for every n ≥ 1.
The trick is to figure out a relation for Fl+5. We observe :
Fl+5 = Fl+4 + Fl+3
= Fl+3 + Fl+2 + Fl+2 + Fl+1
= Fl+3 + 2Fl+2 + Fl+1
= Fl+2 + Fl+1 + 2Fl+2 + Fl+1
= 3Fl+2 + 2Fl+1
= 3(Fl + Fl+1) + 2Fl+1
= 5Fl+1 + 3Fl.
We now are in a position to use a proof by induction. We will prove that F5k−1 is amultiple of 5 for all k ≥ 1. The base case is k = 1. We observe that F4 = 5 which isindeed a multiple of 5. This establishes the base case.
Assume the statement is true for some N . I.e. F5N−1 is a multiple of 5.We now need to show that F5(N+1)−1 is a multiple of 5.Let l = 5N − 1. Notice that l +5 = 5(N +1)− 1. By the work we did earlier, we have:
Fl+5 = 5Fl+1 + 3Fl.
By the induction hypothesis, Fl is a multiple of 5. Clearly 5 divides 5Fl+1. Thus,Fl+5 = F5(N+1)−1 is a multiple of 5. This finishes the induction step.The result now follows by induction.
4. Using the definition, show that
2n2 − 3n + 5 = Θ(n2).
First, we will show that 2n2 − 3n + 5 = O(n2).For n > 0, we have 2n2 − 3n + 5 ≤ 2n2 + 5. If n ≥ 10, we have 2n2 + 5 ≤ 3n2. Thus,we have 2n2 − 3n + 5 ≤ 3n2 for n ≥ 10. This proves the first claim.
We now need to prove that n2 = O(2n2 − 3n + 5).Observe that for n > 3, n2 > 3n. Thus, for n > 3, we have : 2n2−3n+5 > n2+5 > n2.This shows that for n > 3, n2 < 2n2 − 3n + 5. This completes the second half of theargument.
It now follows that 2n2 − 3n + 5 = Θ(n2).
5. (a) Prove thatlog(n!) = O(n log n).
(b) Extend this result : prove that
log(n!) = Θ(n log n).
See the textbook, page 161, example 4.3.9.