1,213 views
0 votes
0 votes
#include <stdio.h>
int f(int n)
{
    if(n ≤ 1)
        return 1;
    if(n%2 = = 0)
        return f(n/2);
    return f(n/2) + f(n/2+1);
}
int main()
{
    printf("%d", f(11));
    return 0;
}


(a) Stack Overflow (b) 3 (c) 4 (d) 5
 

5 Answers

0 votes
0 votes

the answer of this question is option d

try to draw recursion tree of the give code.

0 votes
0 votes

the above program having IF case without else condition simply solve using tree method.

0 votes
0 votes

Start with small values....

F(1)=1

F(2)=F(1)=1

F(3)=F(1)+F(2)=1+1=2

F(11)=F(5)+F(6)=F(2)+F(3)+F(3)=1+2+2=5

Related questions

1 votes
1 votes
0 answers
2