retagged by
365 views

1 Answer

Best answer
1 votes
1 votes

In the LCS (m,n) without using the dynamic programming, the total no. of function call will be O(2m+n) (in the worst case) total call because of the left side of the binary tree has m level of the tree and right level has n level of the binary tree.

and after using the dynamic programming the (only distinct function will be call ) than O(m*n) function call.

u can take the example like LCS(5,4) using the recurrence relation of LCS.

LCS(m,n)= {  o if y[m] == 0 II x[n]== 0

                  { 1 +LCS(m-1,n-1) if y[m] = =x[n]

                  {  Max (LCS(m-1,n) ,LCS(m,n-1)) if  if y[m]  !=x[n]

selected by

No related questions found