Question: Data Structures with Java 7. Consider the following tail-recursive Java function int recFunny (int n) { if (n == 1) { return 1; } else

Data Structures with Java
7. Consider the following tail-recursive Java function int recFunny (int n) { if (n == 1) { return 1; } else { return n % 2 == 0 + recFunny (n / 2) n + recFunny (n - 1); } } ? n : a) What are the restrictions on the values of n, if any? b) Rewrite this function as incFunny in an iterative form without recursion c) What is the output of the following fragment? for (int n = 8; n > 4; --n) { System.out.println("recFunny (" + n + ") = " + recFunny (n)); } Answers: b
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
