Skip to content
DSA Visualizerpreview

Fibonacci 3: bottom-up table

Turn it around: fill the answers from the bottom up, each from the two before it.

O(n) time · O(n), or O(1) keeping two values space

n5

The two base cases go in first: dp[0] = 0 and dp[1] = 1.

View
Table dp[0..5]: 0, 1.

Table dp[0..5]: 0, 1.

  • compare
  • swap or write
  • settled

1 / 6

Speed

Space play · ← → step · Home End jump · drag the strip to scrub