Question: Analyze the following code and from the statements below select those that are true. public class TwoRecursiveMethods { public static void main ( String [
Analyze the following code and from the statements below select those that are true.
public class TwoRecursiveMethods
public static void mainString args
System.out.printlnf;
System.out.printlnf;
public static int fint n int result
if n
return result;
else
return fn n result;
public static int fint n
if n
return ;
else
return n fn ;
Group of answer choices
f is tail recursion, but f is not
For a nonnegative input n f computes n
For a nonnegative input n and initial value of result f computes n
Neither f nor f is tail recursive
For all negative inputs both f and f run infinitely and cause a StackOverflowError
f is tail recursion, but f is not
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
