5 votes 5 votes Consider the following pair of mutually recursive functions. What does $g(g(2))$ evaluate to? int f(int n){ if (n==0) return 0; return f(n-1)+g(n-1); } int g(int n){ if (n==0) return 1; return g(n-1) + f(n); } Programming in C goclasses_wq4 goclasses programming programming-in-c recursion numerical-answers 2-marks + – GO Classes asked Mar 26, 2022 edited May 1, 2022 by Lakshman Bhaiya GO Classes 829 views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
Best answer 9 votes 9 votes Answer : 89 We can draw the recursion tree as follows, reusing the values wherever possible. mayur_dp answered Mar 26, 2022 selected May 9, 2022 by Sachin Mittal 1 mayur_dp comment Share Follow See all 0 reply Please log in or register to add a comment.
4 votes 4 votes Answer is 89 Here is the recursion tree for the question. In this the values in box represents what value will the function hold. We reuse the value of functions calculated.previously. abhishek29 answered Mar 26, 2022 abhishek29 comment Share Follow See all 0 reply Please log in or register to add a comment.
4 votes 4 votes Answer :- 89 from above image - g(g(2)) = g(5) = 89. shishir__roy answered Mar 26, 2022 shishir__roy comment Share Follow See all 0 reply Please log in or register to add a comment.