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 Algorithms algorithms recursion + – Pranav Madhani asked May 26, 2017 Pranav Madhani 1.2k views answer comment Share Follow See 1 comment See all 1 1 comment reply Arunav Khare commented May 26, 2017 reply Follow Share You instead should have run it to get an explanation... Anyways, here is the stack f(11) f(5) + f(6) f(2) + f(3) f(3) f(1) f(1) + f(2) f(1) + f(2) 1 1 f(1) 1 f(1) 1 1 1 1 1 1 votes 1 votes Please log in or register to add a comment.
Best answer 1 votes 1 votes draw the recursion tree pawan kumarln answered May 27, 2017 • selected Aug 13, 2017 by pawan kumarln pawan kumarln comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes the answer of this question is option d try to draw recursion tree of the give code. Sandip Shaw answered May 26, 2017 Sandip Shaw comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes the above program having IF case without else condition simply solve using tree method. Hira Thakur answered Jun 19, 2017 Hira Thakur comment Share Follow See all 2 Comments See all 2 2 Comments reply shraddhatiwary commented Jun 30, 2017 reply Follow Share SIR ...what DFS traversal from left to right mean here...? 0 votes 0 votes Hira Thakur commented Jul 1, 2017 i edited by Hira Thakur Jul 1, 2017 reply Follow Share evaluate like infix expression(left,root,right)??????? 0 votes 0 votes Please log in or register to add a comment.
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 jatin saini answered Jul 3, 2017 jatin saini comment Share Follow See all 0 reply Please log in or register to add a comment.