Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The algorithm below finds the Fibonacci number of sequence of numbers, given the

ID: 3627653 • Letter: T

Question

The algorithm below finds the Fibonacci number of sequence of numbers, given the first two numbers of the sequence (say F1,and F2), the nth number Fn ,n>=3, the sequence Fn of Fibonacci numbers is defined by the recurrence relation
Fn=Fn-1+Fn-2
The following recursive function implements this operation:
Int FibNum (int a, int b, int n){
If(n==1)
Return a;
Else if (n==2)
Return b;
Else
Return FibNum (int a, int b, int n-1)+ FibNum (int a, int b, int n-2);
}


Answer the following questions with explaining the steps of solution:
1. What is the base case for Fibonacci sequence?
2. By using the previous recursive function if you enter the first Fibonacci number =2, the second Fibonacci number=5, what is the Fibonacci number in position 6 of this sequence?

Explanation / Answer

1. The base case is when either of the first two numbers of the sequence are reached (when n is 1 or 2). 2. 31

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote