Hw3-sol - CS 202 Data Structures and Discrete Mathematics II Fall 2010 Homework 3 Solutions 1 Recurrences(60 points(a Find an exact solution to the

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 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 = 1 ,a 1 =- . 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 = 1 = α + β + γ a 1 =- . 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 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 ....
View Full Document

This note was uploaded on 11/22/2010 for the course CS 202 taught by Professor Staff during the Spring '08 term at Ill. Chicago.

Page1 / 9

Hw3-sol - CS 202 Data Structures and Discrete Mathematics II Fall 2010 Homework 3 Solutions 1 Recurrences(60 points(a Find an exact solution to the

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online