Question: Convert the following code to tail recursion. Explain very briefly why a tail recursion is more efficient int fib (int n) { if (n
Convert the following code to tail recursion. Explain very briefly why a tail recursion is more efficient int fib (int n) { if (n <= 2) return 1; return fib (n-1)+fib(n-2); }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
