retagged by
515 views
6 votes
6 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);
}
retagged by

1 Answer

5 votes
5 votes

$\color{Green}\text{Ans: 89}$

Answer:

Related questions

1.0k
views
2 answers
4 votes
GO Classes asked Jan 13
1,011 views
Consider the following two blocks of code, found in separate files:/* main.c */ int main() { int i=0; foo(); return 0; }/* foo.c */ int i=1; void foo() { ... to compile.It will fail to link.It will print " $0$ ".It will print " $1$ ".
448
views
3 answers
3 votes
GO Classes asked Jan 13
448 views
What will be the output of the following program?#include<stdio.h> void swap(char **s1, char **s2){ char *tmp; tmp=*s1; *s1=*s2; *s2=tmp; } int ... [0], strs[1], strs[2]); }pear apple orangeapple pear orangeorange apple pearapple orange pea