• edited by
795 views
0 0 votes

We are given two strings: String 5 of length n and string $T$ of length m for the LC 5 problem, we have produced the following exponential time recursive program.
```
LCM (5, n, T, m)
( if ( }\textrm{n}=0=0||\textrm{m}=0=0) return 0
if (S[n] =m T[m]) result t=1 + LCS (S, n-1, L,m-1);
else result = max (LCS (S, n=1,T,m), LCS (S, n, T,m-1));
return result;
}
```

Then the number of times that LCS (S, 1, T, 1) is recursively called equals $\qquad$

  1. $\binom{n+m-2}{m-1}$
  2. $\binom{n+m+1}{m-2}$
  3. $\binom{n+m+2}{m}$
  4. $\binom{n+m}{m-1}$

1 Answer

0 0 votes

option D is correct because if we make the tree of lcs function calling level of Right  sub tree is m level and left  sub tree is n level than total will be (m+n) .. so that (m+n) will be function call  of this program

Answer:
Position:
Show:

Related questions

2 2 votes
2 2 answers
567
567 views
Nitesh_Yadav asked Apr 11, 2022
567 views
What is the time complexity of the below mentioned recursive function.int f(n){ if(n!=1){ return f(n/2)+f(n/2);}elsereturn 10;} O(n)O(n^2)O(log n)O(n logn)
1 1 vote
1 1 answer
2.9k
2.9k views
Aditya Bahuguna asked Jan 7, 2018
2,926 views
The binary search algorithm is implemented using recursion. Then the space complexity is$\mathrm{O}(1)$$\mathrm{O}(\mathrm{n})$$\mathrm{O}(\log \mathrm{n})$$O(n \log n)$
1 1 vote
3 answers 3 answers
3.0k
3.0k views
shikharV asked Nov 17, 2015
3,027 views
Given answer: BPlease explainDetermine the time complexity of the program segment given below: i=n;while (i>0)(k=1;for (j=1;j
1 1 vote
1 answers 1 answer
1.4k
1.4k views
shikharV asked Nov 15, 2015
1,374 views
The answer to the above problem is A but I am expecting it to be D as constant amount of work is required to solve each subproblem.27Define $A_{i j}^{(k)}=\min \left(A_{i...