Talk:Algorithms/Dynamic Programming

"Note that every leaf of the call tree has the value 0 or 1. All of these ones are summed together to give the final answer, so for any n the number of leaves in the call tree is actually Fn itself!"

Did the author mean to say that there are F(N+1) leaves? If we take the example given, F(6), there are F(6+1) = F(7) = 13 total leaves, *not* F(N) = F(6) = 8. It might also be helpful to mention at this point that there are 2*F(N+1) total nodes and, consequently, 2*F(N+1) total recursive steps required to calculate the Nth number in the sequence.

Please point out where I am wrong.

Calculating fib(n) using its closed form
The author made mention that fib(n) can be calculated efficiently from its closed form. Theoretically I see no problem but I think you have to remember that practically the computer would store the value of the golden ratio in floating point variables which keeps limited precision. Therefore I don't think such an algorithm will be numerically stable. See fibonacci computation for a further discussion of this. Of particular interest is that with standard IEEE 64-bit floats the results break down as early as n=75 and obviously for the standard IEEE 32-bit floats the results breaks down for even smaller n.