recursion - Need helping find examples/instruction -
Some practices are going through, and my book is not very useful in clarifying solutions. T (n) = 2 + T (N - 2): T (n) = n when n% 2 = 0 1) When n% 2 = 1 Thanks! function t (n) {if (n% 2 == 0) return n; And if (n% 2 == 1) returns 2 + T (N-1); } Say that if you use 3, then 3% 2 is checked in the function, which is not 0, so it has pose in other words which is now 3/2 and gives the following: Function T (3) {if (n% 2 == 0) return n; And if (n% 2 == 1) returns 2 + T (N-1); // T (3-1) = T (2)} This will call the same function, but now will be with 2 instead of 2 and the return statement will then be added to the original 2 and likewise, i hope i have explained a bit of function t (2) {if (n% 2 == 0) return n; And if (n% 2 == 1) returns 2 + T (N-1); }