posted Feb 10, 2014, 8:44 AM by Samuel Konstantinovich   [ updated Feb 10, 2014, 12:25 PM ]
By this Friday you must complete the exercises at the end of part 2 and 3 of the student manual. (GridWorld_Case_Study_Student_Manual)

Please use the mailing list for assistance, and help your compatriots. I see great stuff being posted there, keep it up!

By Tomorrow: You should have a working copy of the recursion assignment on a working computer in school. Don't put it in gmail it will take too long.
You can ftp or ssh into the lab, but not marge. is marge, but it is broken. or 102 or 103... up to 130 will work however.
int fact(int n) -  return the value of the n!  Remember 0! is 1, and 1! is also 1.
int fib(int n) - return the value of the nth Fibonacci number. This should be the naive solution from class.
fib(0) is 0   
fib(1) is 1  
fib(2) is 1  
fib(3) is 2   ...etc. 
int fibItr(int n) - return the value of the nth Fibonacci number. This must complete in at most linear time. 

To complete c, you need a different function that allows parameters other than n. 

Pretend you want to find fibItr(5)

You would say: 
0th is 0 (given)
1st is 1 (given)
Other values you need to recurse, so you start to find the next value...
[0, 1] next can be calculated as 1, and i need 3 more (SEE BELOW)
[0, 1, 1 ] next can be calculated as 2, and i need 2 more
[0 1 1 2] next is 3 and i need 1 more.
[0 1 1 2 3] answer is 5.

so you could make a fib function that keeps track of the LAST two values
fibHelp(last,2ndLast,n)   ->  fibHelp(0,1,3)  
and that would call:
fibHelp(1,1,2) which calls:
fibhelp(1,2,1) ... etc.