Question

For the following recursive implementation of a method to compute the Fibonacci S integer n, circle the line number(s) the th
0 0
Add a comment Improve this question Transcribed image text
Answer #1

There are basically 3 steps of recursive function as

1- Base condition also called as terminating condition

2- Recursive call

3-combination step.

2 - 5 line is part of Base condition

line 7 and 8 are two recursive calls

line 9 is combining result of of above two calls.

In below picture comments are showing details

public static Long fibonacci (int n) /*Base condition 2 -5 line/ if (n1) else ifn2) else return 1; return 1; /*Base condition

To see how fibonacci is calculated for n

example n =4.

first of all fibonacci is called. Below is recursion tree for your program

jv iboraccl (万) ibaae) bonacci (2 CBasu tondi thion Ahowing dadon tall

//If you have any doubt.Please feel free to ask.Thanks

Add a comment
Know the answer?
Add Answer to:
For the following recursive implementation of a method to compute the Fibonacci S integer n, circle...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT