Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

JAVA from 26 to 29 pleases 26. What is recursion in Java? 27. The condition that

ID: 3720700 • Letter: J

Question

JAVA

from 26 to 29 pleases

26. What is recursion in Java? 27. The condition that ends a recursive method is called the Without it recursion occurs and causes this type of exception 28. Trace through this method for t(4). What does it evaluate to? Precondition n>-1 public int (int n) if (n 1 n-2) return 2 *r; else return t(n-1)-t (n-2); 29. Write the program Test. It contains a recursive method, mystery, which returns the value of this function F(n) 3, when F(n)-3 * f(n-1) otherwise n 1 The main method calls the recursive method and passes it a value of 3. It prints the result of the call to mystery(3)

Explanation / Answer

26. Recursion in java is a process in which a method calls itself continuously. 26. Blank1: Base case Blank2: Infinite Blank3: StackOverflowError 27. t(4) returns -2 t(3) returns 2 t(2) returns 4 t(1) returns 2 t(2) returns 4 Output = -2 28. 3*f(2) = 3*3*f(1) = 3*3*3 = 9