State two advantages and two disadvantages of recursion compared with iteration.
Recursion
Original Khojo Papers practice question — not from a past board paper.
int fib(int n) { if (n == 0) return 0; if (n == 1) return 1; return fib(n - 1) + fib(n - 2); }
No citable source has been recorded for this record. Treat it as practice material, not as fact.
This simple version recomputes the same values many times, so its running time grows exponentially; an iterative version is linear.
From the same topic and chapter, at a similar level.
State two advantages and two disadvantages of recursion compared with iteration.
Recursion
Write a recursive Java method to find the greatest common divisor of two positive integers.
Recursion
How many times is the method called in total when fact(5) is executed, taking fact(0) as the base case?
Recursion
Write a recursive Java method to reverse a string.
Recursion
Write a recursive Java method to compute the factorial of a non-negative integer n.
Recursion
State and verify the absorption law X + X·Y = X using a truth table.
Boolean Algebra