Mohamed G. Gouda CS 313K Fall 2012 Exercise 12 1. Use the Characteristic Polynomial method to compute the closed equation for the following recurrence equation: T(0) = 4 (1) T(1) = 3 (2) T(n+2) = 3*T(n+1) + 4*T(n) for n >= 0 (3) Sol: The Characteristic Polynomial from (3) is: t^2 = 3*t + 4 t^2 - 3*t - 4 = 0 (t+1)(t-4) = 0 t1 = -1 and t2 = 4 Expression for T(n): T(n) = x*(-1)^n + y*(4)^n (4) From (1) and (4): 4 = x + y (5) From (2) and (4): 3 = -x + 4*y (6) From (5) and (6), x = 13/5 and y = 7/5 (7) The closed equation from (4) and (7): T(n) = (13/5)*(-1)^n + (7/5)*(4)^n 2. Use two methods, i.e. Poorman's Induction and Characteristic Polynomial, to derive the closed equation for the following recurrence equation: T(0) = 7 (1) T(n+1) = 2*T(n) (2) Sol: Poorman's Induction Method From (2), T(n) = 2*T(n-1) = (2^2)*T(n-2) = (2^3)*T(n-3) ... = (2^i)*T(n-i) = {Choosing i to be n} (2^n)*T(0) = {From (1)} (2^n)*7 Characteristic Polynomial The Characteris Polynomial from (2) is: t = 2 This polynomial has one root t1 whose value is 2. Expression for T(n): T(n) = x*(t1)^n = x*(2)^n From (1), we get 7 = x*1 The closed equation is: T(n) = 7*(2^n) 3. Use the Characteristic Polynomial method to compute the closed equation for the following recurrence equation: T(0) = 6 (1) T(1) = 8 (2) T(n+2) = 4*T(n+1) - 4*T(n) for n >= 0 (3) Sol: The Characteristic Polynomial from (3) is: t^2 = 4*t - 4 t^2 - 4*t + 4 = 0 (t-2)^2 = 0 t1 = 2 and t2 = 2 Expression for T(n): T(n) = x*(2)^n + y*n*(2)^n (4) From (1) and (4): 6 = x (5) From (2), (4) and (5): 8 = 2*6 + 2*y y = -2 (6) From (5) and (6), x = 6 and y = -2 (7) The closed equation from (4) and (7): T(n) = 6*(2)^n - 2*n*(2)^n 4. Use the Characteristic Polynomial method to compute the closed equation for the following recurrence equation: T(0) = 1 (1) T(1) = 1 (2) T(2) = 2 (3) T(n+3) = (-2)*T(n+2) + T(n+1) + 2*T(n) for n >= 0 (4) Sol: The Characteristic Polynomial from (4) is: t^3 = -2*t^2 + t + 2 t^3 + 2*t^2 - t - 2 = 0 (t+1)(t-1)(t+2) = 0 t1 = -1, t2 = 1 and t3 = -2 Expression for T(n): T(n) = x*(-1)^n + y*(1)^n + z*(-2)^n (5) From (1), (2), (3) and (5): x = -1/2, y = 7/6, and z = 1/3 (6) The closed equation from (5) and (6): T(n) = (-1/2)*(-1)^n + (7/6) + (1/3)*(-2)^n 5. Use the Characteristic Polynomial method to compute the closed equation for the following recurrence equation of Lucas Numbers: T(0) = 2 (1) T(1) = 1 (2) T(n+2) = T(n+1) + T(n) for n >= 0 (3) Sol: The Characteristic Polynomial from (3) is: t^2 = t + 1 t^2 - t - 1 = 0 {Hint: The two roots are (-b + sqrt(b^2 - 4ac))/2a and (-b - sqrt(b^2 - 4ac))/2a.} t1 = (1 + sqrt(5))/2 and t2 = (1 - sqrt(5)) / 2 Expression for T(n): T(n) = x*((1 + sqrt(5))/2)^n + y*((1 - sqrt(5))/2)^n (4) From (1), (2), and (4): x = 1 and y = 1 (5) The closed equation from (4) and (5): T(n) = ((1 + sqrt(5))/2)^n + ((1 - sqrt(5))/2)^n 6. Consider the recurrence equation of Lucas Numbers: T(0) = 2 T(1) = 1 T(n+2) = T(n+1) + T(n) for n >= 0 Prove, by induction, that T(n) = F(n+1) + F(n-1) for n >= 2 where F(n) is the n-th Fibonacci Number. Sol: Let P(n) be the predicate T(n) = F(n+1) + F(n-1). Base Case: n=2 and n=3: P(2) <=> T(2) = T(1)+T(0) = 1+2 = F(3)+F(1) <=> T P(3) <=> T(3) = T(2)+T(1) = 3+1 = F(4)+F(2) <=> T Induction Step: For n >= 2, P(n-1) and P(n) => P(n+1) T => {Definition of T(n+1)} T(n+1) = T(n) + T(n-1) => {Induction Hypothesis: P(n-1) and P(n)} T(n+1) = (F(n+1)+F(n-1)) + (F(n)+F(n-2)) => {Definition of Fibonacci Numbers} T(n+1) = F(n+2) + F(n) => {Definition of P(n+1)} P(n+1) 7. Use the Characteristic Polynomial method to compute the closed equation for the following recurrence equation: T(0) = 2 (1) T(1) = -4 (2) T(n+2) = 2*T(n+1) - T(n) for n >= 0 (3) Sol: The Characteristic Polynomial from (3) is: t^2 = 2*t - 1 t^2 - 2*t + 1 = 0 (t-1)^2 = 0 t1 = 1 and t2 = 1 Expression for T(n): T(n) = x*(1)^n + y*n*(1)^n = x + y*n (4) From (1) and (4): 2 = x (5) From (2), (4), and (5): -4 = 2 + y y = -6 (6) The closed equation from (4), (5), and (6): T(n) = 2 - 6*n