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

Computer Science & Information Technology

You might also like to view...

Unlike DTDs, schemas do not use a single standard.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

Write the blue and green versions of the reduce red function—Program 9

What will be an ideal response?

Computer Science & Information Technology

Using the code from above, which is the SetBookName function located in Book.cpp?

Declare an instance of Book from the above code: ``` class Book { private: int num_pages; string title; public: Book(); void SetBookName(string bn); }; ``` A. Mybook Book; B. Book Mybook; C. Book( ) Mybook( ); D. Book Mybook( );

Computer Science & Information Technology

List three features that the MIME standard provides.

What will be an ideal response?

Computer Science & Information Technology