Question: Consider following recursive method and answer the questions. public int luc(int n) { if(n == 1) return 2; if(n == 2) return 1; return luc(n-1)
Consider following recursive method and answer the questions.
public int luc(int n) {
if(n == 1) return 2;
if(n == 2) return 1;
return luc(n-1) + luc(n-2);
}
a) what does this method do?
b) compute and trace luc(8)
c) In part b, how many times luc(5) calculated?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
