Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

5. (10 pts) Suppose that you have a function int Fibonacci (int n) which takes in a positive integer n and returns the nth Fibonnacci

image text in transcribed

5. (10 pts) Suppose that you have a function int Fibonacci (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 Fibonacci(n-1) + Fibonacci (n-2) when n > 2. In addition, assume that your function writes out BGN Fibonacci n at the start of the function, and writes out END Fibonacci 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 Fibonacci Maximum value of BGN-END Here in the second row, you are to write out the maximum value (during the execution of the program) of the number of BGN printed out minus the number of END printed out. 5. (10 pts) Suppose that you have a function int Fibonacci (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 Fibonacci(n-1) + Fibonacci (n-2) when n > 2. In addition, assume that your function writes out BGN Fibonacci n at the start of the function, and writes out END Fibonacci 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 Fibonacci Maximum value of BGN-END Here in the second row, you are to write out the maximum value (during the execution of the program) of the number of BGN printed out minus the number of END printed out

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional SQL Server 2012 Internals And Troubleshooting

Authors: Christian Bolton, Justin Langford

1st Edition

1118177657, 9781118177655

More Books

Students also viewed these Databases questions

Question

What does this public know about your organization?

Answered: 1 week ago

Question

consider the following ER model construct an ( ODL)

Answered: 1 week ago

Question

1. What are the peculiarities of viruses ?

Answered: 1 week ago

Question

Describe the menstrual cycle in a woman.

Answered: 1 week ago