Question: Write an iterative function gibonacci_I(n) to compute gn without using any recursion. Hi, I just want the solution for iterative Gibonacci number in Python. Code



Write an iterative function gibonacci_I(n) to compute gn without using any recursion. Hi, I just want the solution for iterative Gibonacci number in Python. Code in Python.
Question 2: Gibonacci You may have learned in Lecture 04 that Fibonacci sequence is an answer to the question of How many adult rabbit pairs are there at month m> 0 when: (1) The population begins in the first month with a pair of newborn rabbits. (2) Rabbits reach reproductive age after one month (3) In any given month, every rabbit of reproductive age mates with another rabbit of reproductive age. (4) Exactly one month after two rabbits mate, they produce one male and one female rabbit. (5) Rabbits never die or stop reproducing We can answer the question by the recursive formula: la = 0, /i = 1 and fn = In-1 +/x-2. Number of pairs 1 1 Here we have a slightly different problem. We make modification to the recursive formula as follows: go = 0.91 = 0,92 = 1 and 9 = 9n-1 +90-3. Note that instead of fr-1 and -2, we have ga 1 and 9. 3. Why do we use this formula? Let's just say that maybe the rabbit becomes adult after 2 months instead of 1 month. We call this sequence the gibonacci sequence. This is explained in the image below: Month #Adult Legends: baby rabbit young adult rabbit 0 0 1 0 adult rabbit 2 1 3 4 1 5 2 0000 0.0 0.0 Figure 2: The gibonacci sequence explained. 2.1 Recursion [10 marks) Question Write a recursive function gibonacci_A(n) to compute , by using recursion without using any repetition statement. Restrictions You may not use iterative constructs (e.g., loop, list comprehensions, etc.) to solve this. The function gibonacci R must be recursive (i.c., it calls itsell). The use of any recursive helper functions will not be counted as being recursive. Assumptions .. >= 0 Sample Run #1 >>> print (gibonacci_R(4) 1 Sample Run #2 >>> print(gibonacci_R(10)) 13 Sample Run #3 >>> print(gibonacci_R(15)) 88 2.2 Iteration [15 marks] Question Write an iterative function gibonacci_I(n) to compute Gr without using any recursion. Restrictions . You may not use recursive function(s) to solve this. Assumptions .n>= 0 Hint We showed the iterative Fibonacci in Lecture 04, can you modify it to Gibonacci? 5 Sample Run #1 >>> print (gibonacci_I(4)) 1 Sample Run #2 >>> print(gibonacci I(10)) 13 Sample Run #3 >>> print(gibonacci_I(15)) 88 2.3 Maximum [5 marks) Reflections Find the largest output number that your functions can compute within 1 minute in Question 2.1 and Question 2.2. You don't have to find an exact tight bound, but something close is good cnough. Which version is better and in what ways? Write your thoughts in the comment part of your .py file. Notes Use scientific notation (e.)., 2 x 103 ) if your answer is too big, If it is still too big, you may reduce the time (0.9., 30 seconds instead of 1 minutes) and mention that in your reflections. 6
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
