java - recursion: determining limiting condition -
I have incomplete handout about recursion and an example asks if the "limited status" of this particular recurrence method Is: Options are: If "limited condition" means that this method is valid, then I think the answer is n & gt; = 1? You're right. Note that if The method provided assumes that (1) Do not pay attention to the integer overflow here .... > Public Static Ent Fib (int a, int b, int n) {if (n = 1 1) returns; And if (n == 2) return b; And reboot fib (A, B, N-1) + Fib (A, B, N-2); }
n & lt; 1 In each trip, you will reduce
n by 1 (or 2) and do not exceed 1
n & gt; 1 To work properly, in some places it is called pre-condition.
Comments
Post a Comment