{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

2c03-review - 00064 - b Assume T(k,k)=T(j,0)=c for all j,k...

Info icon This 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: 0 0 0 0 ( ) [min( 2 , 2 ),max( 2 , 2 )] [min(2 ,2 ),max(2 ,2 )] ( 2 ) n m m n m m i i i i n m m n m m n i i i i T n 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
Image of page 1
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern