2c03-review - 00064

2c03-review 00064 - b Assume T(k,k)=T(j,0)=c for all j,k and for making reasoning easier T(i,j)=0 if j<0 T(n,m)=T(n-1,m T(n-1,m-1

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
7 b. Assume T(k,k)=T(j,0)=c for all j,k, and for making reasoning easier T(i,j)=0 if j<0. T(n,m)=T(n-1,m)+T(n-1,m-1)+1 (n,m) / \ (n-1,m) (n-1,m-1) / \ / \ (n-2,m) (n-2,m-1) (n-1,m-1) (n-2,m-2) ….. One solution, by using “recursion tree” in pure form: In the worse case we have m=n/2: 00 ( ) [min( 2 , 2 ),max( 2 , 2 )] [min(2 ,2 ),max(2 ,2 )] ( 2 ) nm m m ii n m m n m m n Tn O −− == ∈= = ∑∑ , i.e. T(n) = O(2 n/2 ). Another solution, less tricky but longer, by using “expansion method” T(n,m)=T(n-1,m)+T(n-1,m-1)+c= T(n-2,m)+2T(n-2,m-1)+T(n-2,m-2)+(1+2)c= T(n-3,m)+3T(n-3,m-1)+3T(n-3,m-2)+T(n-3,m-3)+(1+2+4)c= .... C(0,k)T(n-k,m)+C(1,k)T(n-k,m-1)+C(2,k)T(n-k,m-2)+. ..+C(i,k)T(n-k,m-i)+. .. +C(k-1,k)T(n-k,m-k+1)+C(k,k)T(n-k,m-k)+ (1+2+4+8+. ..+2 k )= C(0,k)T(n-k,m)+C(1,k)T(n-k,m-1)+C(2,k)T(n-k,m-2)+. ..+C(i,k)T(n-k,m-i)+. .. +C(k-1,k)T(n-k,m-k+1)+C(k,k)T(n-k,m-k)+ (2 k+1 -1)c Because of “T(k,k)=T(j,0)=c for all j,k”, all T(i,j) become equal to c at some point, but
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/10/2009 for the course CAS 2c03 taught by Professor Janicki during the Spring '03 term at McMaster University.

Ask a homework question - tutors are online