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.
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
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));
@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}
is an error, the mathematical definition is as you wrote it
Okay then! thanks!
http://www.youtube.com/watch?v=WbWb0u8bJrU&feature=player_embedded minute 42 he explained why take fib(0)==1
Join our real-time social learning platform and learn together with your friends!