{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

hw3-sol

# hw3-sol - CS 202 Data Structures and Discrete Mathematics...

This preview shows pages 1–3. Sign up to view the full content.

CS 202: Data Structures and Discrete Mathematics II Fall 2010 Homework 3 () Solutions 1. Recurrences (60 points) (a) Find an exact solution to the following recurrence: a n = a n - 1 + 2 a n - 2 + 3 n 2 - 16 n + 17 . 5 , with a 0 = 1 , a 1 = - 0 . 5 Solution: To solve recurrence a n = a n - 1 + 2 a n - 2 + 3 n 2 - 16 n + 17 . 5 The homogeneous annihilator is E 2 - E - 2 = ( E - 2)( E + 1). The residue is h- 6 n 2 + 38 n - 42 i which is annihilated by ( E - 1) 3 . The annihilator is ( E - 2)( E + 1)( E - 1) 3 , and the generic solution is a n = α 2 n + β ( - 1) n + γ + δn + n 2 . The constants α, β, γ, δ, satisfying the equations a 0 = 1 = α + β + γ a 1 = - 0 . 5 = 2 α - β + γ + δ + a 2 = - 1 = 4 α + β + γ + 2 δ + 4 a 3 = - 5 . 5 = 8 α - β + γ + 3 δ + 9 a 4 = - 6 = 16 α + β + γ + 4 δ + 16 are 1 , 3 4 , - 3 4 , 1 2 , - 3 2 respectively, The closed form of the recurrence is a n = 2 n + 3 4 ( - 1) n - 3 2 n 2 + n 2 - 3 4 . (b) Let a n be the number of additions performed in evaluating the determinant of an n × n matrix by the cofactor expansion method (expansion by minors) 1 . i. Write a recursive formula for a n . Justify briefly. Solution: a n = n · a n - 1 + n - 1 a 1 = 0 Explanation: Computing the determinant of an n × n matrix involves computing the de- terminants of n other matrices, each of size ( n - 1) × ( n - 1). Once those are computed we then add them all together. The number of additions performed to compute a determinant of an n × n matrix must be the number of additions to compute the determinant of an 1 See http://mathworld.wolfram.com/DeterminantExpansionbyMinors.html 3-1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
CS 202 Homework 3 ( n - 1) × ( n - 1) matrix multiplied by n because that’s how many ( n - 1) × ( n - 1) matrices there and then plus the n - 1 additions necessary to sum up all the determinants. The base case is set to n = 1 to represent the situation when the matrix is of size 1 × 1 which is really just a single scalar number requiring no computation work at all. ii. The solution to the recursion is a n = n ! - 1. iii. Prove that your formula correctly expresses the number of additions, a n . Solution: We’ll use a Proof by Induction to show that our recurrence relation in part i matches the exact solution in part ii . In other words we’ll show n · a n - 1 + n - 1 = n ! - 1 Base Case: n = 2 . For n = 2, we get: Left Hand Side (LHS) = 2 · 0 + 2 - 1 = 1 Right Hand Side (RHS) = 2! - 1 = 2 - 1 = 1 Both sides are equal which proves the base case. Inductive Hypothesis: Assume that the recurrence relation is true for all a k where 2 k < n . Inductive Step: Prove the recurrence relation is also correct for n . Proof: a n = n · a n - 1 + n - 1 by the definition of a n = n · (( n - 1)! - 1) + n - 1 by the inductive hypothesis = n ! - n + n - 1 = n ! - 1 This proves the recurrence relation from part i is equal to the exact equa- tion given in part ii for a n . End of proof: Since the base case and the inductive step hold, the state- ment is true for all n 2. (c) Weiss, 4th edition, Ch 7, Ex 7.17(e), 7.18(c,h) Solve the recurrences using both the recursion tree and the Master Theorem method.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern