edited by
1,442 views
7 votes
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 __________ .

edited by

1 Answer

Best answer
9 votes
9 votes

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

selected by
Answer:

Related questions

0 votes
0 votes
2 answers
1
Debargha Mitra Roy asked Apr 10
121 views
What is the output of the below code?#include <stdio.h void main() { static int var = 5; printf("%d ", var ); if (var) main(); }a. 1 2 3 4 5b. 1c. 5 4 3 2 1d. Error
3 votes
3 votes
3 answers
2
Laxman Ghanchi asked May 19, 2023
1,177 views
#include<stdio.h void print(int n) { printf("Hello "); if(n++ == 0) return ; print(n); n++; } int main() { void print(); print(-4); }How many times printf execute?? And H...
0 votes
0 votes
1 answer
3
Laxman Ghanchi asked May 19, 2023
693 views
#include<stdio.h>void print(int n){ printf("Hello "); if(n++ == 0) return ; print(n); n++;}int main(){ void print(); print(-4);}