Save your work here: .../APCSA_1/apcsa-assignments-YourUsername/classwork/36_fibonacci_iterative/
-
Draw the call stack for fibIter(10, 1, 0) in your notebook, take a picture and upload it to your repo.
-
Let's implement the iterative Fibonacci algorithm. Create a Fibonacci.java file and implement the following method:
/*
* Preconditions:
* n is a non-negative integer
* n refers to the nth element in the fib sequequence
* initial f1 value is 1
* initial f2 value is 0
*/
public static int fibIter(int n, int f1, int f2){
// remember the recursive case calls fibIter once
}