(Solved) : 5 10 Pts Suppose Function Int Fib Int N Takes Positive Integer N Returns Nth Fibonnacci Nu Q44106877 . . .
5. (10 pts) Suppose that you have a function int Fib(int n) which takes in a positive integer n and returns the nth Fibonnacci number. Assume that your function is in recursive form: it returns 1 when n=1 or n=2, and returns Fib(n-1) + Fib(n-2) when n > 2. In addition, assume that your function writes out BGN Fib n at the start of the function, and writes out END Fib n before the end of the function, where n is the value of the input parameter. You also have a main program which reads in a positive integer k and calls Fibonacci(k). Also assume that your main program writes out BGN main at the start of the program, and writes out END main before it stops. k=1 k=5 k=10 k=20 k=40 Total number of calls to Fib Maximum value of “BGN Fib” – “END Fib” Here in the second row, you are to write out the maximum value (during the execution of the program) of the number of BGN Fib printed out minus the number of END Fib printed out. Show transcribed image text 5. (10 pts) Suppose that you have a function int Fib(int n) which takes in a positive integer n and returns the nth Fibonnacci number. Assume that your function is in recursive form: it returns 1 when n=1 or n=2, and returns Fib(n-1) + Fib(n-2) when n > 2. In addition, assume that your function writes out BGN Fib n at the start of the function, and writes out END Fib n before the end of the function, where n is the value of the input parameter. You also have a main program which reads in a positive integer k and calls Fibonacci(k). Also assume that your main program writes out BGN main at the start of the program, and writes out END main before it stops. k=1 k=5 k=10 k=20 k=40 Total number of calls to Fib Maximum value of “BGN Fib” – “END Fib” Here in the second row, you are to write out the maximum value (during the execution of the program) of the number of BGN Fib printed out minus the number of END Fib printed out.
Expert Answer
Answer to 5. (10 pts) Suppose that you have a function int Fib(int n) which takes in a positive integer n and returns the nth Fibo…
OR