Bottom-up Fibonacci: Visualization of JS code execution

preview_player
Показать описание
We start with the JavaScript code for generating Fibonacci numbers using the bottom-up approach, and visualize the step-by-step execution using JavaScript tutor.
Try it yourself here:
Рекомендации по теме
Комментарии
Автор

I have a couple of questions -
1. Isn't this video supposed to be explaining the fibonacci number generation up to n ? i.e. If fib(5) - 0, 1, 1, 2, 3, 5 or 0, 1, 1, 2, 3 (depending on what n is). Instead, we seem to be returning just one value : fib(5) = 5 ? Does that mean we're returning the nth number in the fibonacci series - 0, 1, 1, 2, 3, 5, 8, 13, 21, 34 ? If so, shouldn't the 5th number be 3?

2. Why is this called bottom up approach? I read in your associated document : "When using a bottom-up approach, the computer solves the sub-problems first and uses the partial results to arrive at the final result." But isn't that what recursion also does ?

nocturnalstoryteller