Write a recursive Java method to compute the nth term of the Fibonacci sequence, taking the first two terms as 0 and 1.
Recursion
Original Khojo Papers practice question — not from a past board paper.
String rev(String s) { if (s.length() <= 1) return s; return rev(s.substring(1)) + s.charAt(0); }
No citable source has been recorded for this record. Treat it as practice material, not as fact.
The base case is a string of length zero or one, which is its own reverse.
From the same topic and chapter, at a similar level.
Write a recursive Java method to compute the nth term of the Fibonacci sequence, taking the first two terms as 0 and 1.
Recursion
Write a recursive Java method to find the greatest common divisor of two positive integers.
Recursion
Write a recursive Java method to compute the factorial of a non-negative integer n.
Recursion
State two advantages and two disadvantages of recursion compared with iteration.
Recursion
How many times is the method called in total when fact(5) is executed, taking fact(0) as the base case?
Recursion
Reduce F(A, B, C) = Σ(0, 1, 2, 3) using a Karnaugh map.
Karnaugh Maps