edited by
2,839 views
7 7 votes

Consider the following recursive function which is used by dynamic programming.

Assume for every function call T(i) it checks the table first, if its value is already computed it retrieves the value from table. Otherwise it calls a recursive function call to compute its return value. Whenever a function T(i) computes for first time its return value is stored in the table to avoid the redundant function calls.
The number of function calls that need the support of stack to complete the execution of the function T(12) are __________ .

1 Answer

Best answer
9 9 votes

It should be $\large\color{red}{21}$

selected by
Answer:
Position:
Show:

Related questions

8 8 votes
3 3 answers
380
380 views
GO Classes asked Jun 17
380 views
What is the output of the following code?#include <stdio.h void update(int n, int *p) { if (n <= 0) return; *p = *p + n; update(n - 2, p); *p = *p + n; } int main() { int...
6 6 votes
2 2 answers
321
321 views
GO Classes asked Jun 17
321 views
What is the output of the following code?#include <stdio.h int fun(int n) { int x = n; if (n <= 0) return 0; x = x + 2; return x + fun(n - 2); } int main() { printf("%d",...
5 5 votes
4 4 answers
333
333 views
GO Classes asked Jun 16
333 views
What is the output of the following code?#include <stdio.h void g(int n); void f(int n) { if (n <= 0) return; printf("F%d ", n); g(n - 1); printf("f%d ", n); } void g(int...
6 6 votes
3 3 answers
315
315 views
GO Classes asked Jun 16
315 views
What is the output of the following code?#include <stdio.h void fun(int n) { static int x = 0; if (n == 0) return; x++; printf("%d:%d ", n, x); fun(n - 1); printf("%d:%d ...