Fibonacci DP Visualizer

Choose an index, fill the Fibonacci table from the base cases, and inspect how each value reuses the previous two answers.

n
8
fib(n)
21
Index
0
Step
1

Input

Step controls

Set base case fib(0) = 0.

Fibonacci table

0
1
2
3
4
5
6
7
8
0 fib(0)
- fib(1)
- fib(2)
- fib(3)
- fib(4)
- fib(5)
- fib(6)
- fib(7)
- fib(8)

DP output

operation = Base
index = 0
left = -
right = -
fib_n = 21

Recurrence

fib(0) = 0
fib(1) = 1
fib(n) = fib(n - 1) + fib(n - 2)

What is a Fibonacci DP Visualizer?

A Fibonacci DP visualizer shows how the Fibonacci sequence can be computed with dynamic programming instead of repeated recursion. This page uses bottom-up tabulation.

Choose n, then step through the base cases and each table update until the tool reaches fib(n).

For the full algorithm set, browse the Data Structure Visualizers hub.

How to use this Fibonacci visualizer

  • Choose the Fibonacci index n.
  • Click Run Fibonacci DP to fill the table.
  • Step forward to see each value depend on the two previous values.
  • Inspect the final fib(n) value in the output panel.

Fibonacci and dynamic programming

Naive recursive Fibonacci recomputes the same subproblems many times. Dynamic programming stores earlier answers so each Fibonacci number is computed once.

For related DP practice, compare this page with the Longest Increasing Subsequence Visualizer, Coin Change DP Visualizer, and Recursion Tree Visualizer.

Frequently Asked Questions

What does bottom-up Fibonacci mean?
Bottom-up Fibonacci starts from fib(0) and fib(1), then fills fib(2), fib(3), and so on until the target index.
What is the recurrence for Fibonacci DP?
The recurrence is fib(n) = fib(n - 1) + fib(n - 2), with fib(0) = 0 and fib(1) = 1.
Why is dynamic programming faster than naive recursion?
Dynamic programming stores each smaller Fibonacci value, so each subproblem is solved once instead of being recomputed many times.
What is the time complexity of bottom-up Fibonacci?
Bottom-up Fibonacci runs in O(n) time and O(n) space when storing the full table.

Related tools