Tabulating Fibonacci Numbers
Let's tabulate the code to find the nth Fibonacci number now.
We'll cover the following
Lets find the Fibonacci number using bottom-up tabulation. This approach uses iteration and can essentially be thought of as recursion in reverse.
Pseudocode
Initialize look up table of length n+1
Set first two values to 0 and 1
For i = 2 till n-1:
lookuptable = lookuptable[i-1] + lookuptable[i-2]
return lookuptable[n];
Tabulated Version #1
Have a look at the tabulated code in C++,
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.