we know that the tabular computation of a dynamic- programming algorithm helps us to avoid recomputation. prove it using the example of fibonacci numbers.
The tabular computation of the dynamic programming is a first filling up table. In this we can say that the dynamic programming
var fibBotUp = (n) => {
var member = [];
for (var i=0; i <=n; i++) {
if (i == 0) member[i] = 0;
else if (i <=2) member[i] = 1;
else {
member[i] = member[i-1] + member[i-2];
}
}
return mem[n];
}
Comments
Leave a comment