Analyze the following functions;
```
public class Test1 {
public static void main(String[] args) {
System.out.println(f1(3));
System.out.println(f2(3, 0));
}
public static int f1(int n) {
if (n == 0)
return 0;
else {
return n + f1(n - 1);
}
}
public static int f2(int n, int result) {
if (n == 0)
return result;
else
return f2(n - 1, n + result);
}
}
```
a. f1 is tail recursion, but f2 is not
b. f2 is tail recursion, but f1 is not
c. f1 and f2 are both tail recursive
d. Neither f1 nor f2 is tail recursive
b
You might also like to view...
Today more than two-thirds of all users access their favorite social media, at least some of the time, from their smartphones and other mobile devices
Indicate whether the statement is true or false
HIPAA states that record disposal is the responsibility of hospitals only
Indicate whether the statement is true or false