in Algorithms edited by
1,045 views
0 votes
0 votes

Consider the two given functions:

int fun1(int x, int y)
{
if (y==0) return 0;
return (x+fun2(x, y-1));
}

int fun2(int x, int y)
{
if (x==0)
return y;
return fun2(x-1, x+y);
}



What will be the value returned by $\text{fun1}(4, 4)$ ____

in Algorithms edited by
1.0k views

2 Comments

17?
0
0
Answer must be 17
0
0

2 Answers

3 votes
3 votes
f1(4,4)->4+f2(4,3)->f2(3,7)->f2(2,10)->f2(1,12)->f2(0,13) return 13

in f1()->4+13=17
0 votes
0 votes

So return value  of  $\text{fun1}(4,4)= 17$

 

Answer:

Related questions