int fib(int i) {
if(i<2) {
return 1;
}
else {
return fib(i-1) + fib(i-2) ;
}
}
I am not able to understand how the statements return fib(i-1) + fib(i-2)
is processed???
Does fib(i-1)
is process first and fib(i-2)
or both get processed simultaneously??
Also, suppose fib(i-1)=3
, then in this case how fib(i-1)=3
gets calculated..i know that this further get called to fib(i-1)=2
and fib(i-1)=1
which give 1
as return in both cases. Then how does fib(i-1)=3
gets calculated based on fib(i-1)=2
and fib(i-1)=1
???