This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Consider the recurrence relation R ( n ) = { if n = 0 R ( n1) + 2 n 2 if n > 0 Which of the following formulae is a solution to R ( n )? 2 n 2 n 2 2 n 2 n n 2 2 n 2 n 2 2 n Proof. R (0) = 0 = (0 2 0). For n > 0, suppose (as an inductive hypothesis) R ( n1) = ( n1) 2 ( n1). Then R ( n ) = R ( n1) + 2 n 2 by definition = ( n1) 2 ( n1) + 2 n 2 by i.h. = n 2 2 n + 1  n + 1 + 2 n 2 some algebra = n 2 + (2 n 2 n )  n + (2  2) rearranging terms = n 2 n eliminating zero terms Q.E.D. recursion,recurrence relation,closed form solution,induction Let s be a binary string, and define a function C ( s ) recursively as: B. If s = , then C ( s ) = 0. R1. If s = s' 0 for some binary string s' , then C ( s ) = C ( s' ) + 1. R2. If s = s' 1 for some binary string s' , then C ( s ) = C ( s' ). What is the value of C (00110)? 2 3 5 6 7 We evaluate C (00110) from the top down: C (00110) = C (0011) + 1 by part R1 = C (001) + 1 by part R2 = C (00) + 1 by part R2 = C (0) + 1 + 1 by part R1 =...
View
Full
Document
This note was uploaded on 07/28/2009 for the course CSE 21 taught by Professor Graham during the Spring '07 term at UCSD.
 Spring '07
 Graham

Click to edit the document details