Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Assignment Recursion

Fibonacci sequence

In this assignment you will explore the Fibonacci sequence.

Requirements:

1. Describe the sequence (start the sequence with 0 and 1 as default).

2. Write the rule to construct each term and as a recursive Function.

3. Write the iterative program in C# to calculate a specific term in that sequence. Use
values of 0 and 1 as starting values.

4. Write the recursive program in C# to calculate a specific term in that sequence. Use
values of 0 and 1 as base cases.

5. Draw the recursion call tree for n = 5

6. Find how many calls = recursion depth are for different inputs;
examples: n = 5, n = 6, n = 7, n = 10, n = 15, n = 20, n = 45
7. Test both algorithms for the above inputs; Record the code execution time for n =7 and
n = 45 for both algorithms. Describe which algorithm do you think is more efficient.

8. Search for additional information regarding this sequence (at least 4 examples).
(Example: Fibonacci sequence in nature).

You might also like