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. f2 is tail recursion, but f1 is not

Computer Science & Information Technology

You might also like to view...

How does file protection based on access permissions work? Base your answer on various types of users of a file and the types of operations they can perform. How many permission bits are needed to implement this scheme? Why?

What will be an ideal response?

Computer Science & Information Technology

What is the primary difference between previous Microsoft operating systems and Windows 8?

A) Voice activation capabilities B) Advanced levels of Web and personal identification security C) Advanced levels of child safety and social media security D) Touch screen capabilities

Computer Science & Information Technology

What does the term ?mounting? mean?

What will be an ideal response?

Computer Science & Information Technology

____ can turn static documents into applications such as games or calculators.

A. HTML B. XHTML C. JavaScript D. Cascading Style Sheets

Computer Science & Information Technology