Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 7 Online
OpenStudy (anonymous):

In Lecture 13 while explaining memoisation, the prof. actually takes fib(0) to be 1. Though Fibonacci series is 0 1 2 3 5 8 13 etc., fib(0) shoule be 0, fib(1) should be 1 and so on. I know I'm missing something, please correct me.

OpenStudy (lopus):

Fibonacci both 0 and 1 are two cases separately and apart from 2 starts with the algorithm: \[F _{n}=F _{n-1}+F _{n-2}\] base case: f(0)=0 f(1)=1

OpenStudy (lopus):

fib(0)=0 fib(1)=1 fib(2)=1 fib(3)=2 if ( n == 0 || n == 1) return n; else return (fibonacci(n-1) + fibonacci(n-2));

OpenStudy (anonymous):

@lopus This exactly what I mean but acc to the lecture, if n<=1: return 1 which returns 1 in both 0 and 1. Also, he clearly specifies fib(0) = 1 and fib(1) = 1 in the memory as {0:1, 1:1}

OpenStudy (lopus):

is an error, the mathematical definition is as you wrote it

OpenStudy (anonymous):

Okay then! thanks!

OpenStudy (lopus):

http://www.youtube.com/watch?v=WbWb0u8bJrU&feature=player_embedded minute 42 he explained why take fib(0)==1

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!