Advanced · Module 15 · Lesson 2 of 6
Bottom-up tables
Instead of recursing and caching, fill an array of answers in an order where every value a cell needs has already been computed. No recursion, no lookups, and the structure of the table becomes visible.
By the end you can
- Turn a recurrence into a table filled with loops in dependency order
- Write a DP precisely: the meaning of a cell, the recurrence, the base cases, the order and where the answer is
- Choose between top-down memoization and bottom-up tabulation
Builds on Memoization.
01 · A question first
A memoized solution handles n = 1,000 and crashes with a recursion error at n = 100,000. The same recurrence, filled into an array from the bottom up, handles a million with no recursion at all. What decides the order in which to fill the array?
Make a guess before you read on.
02 · The idea
Members only
Unlock the full lesson
This lesson is part of the membership. Join to read it in full, along with every other premium deep dive.
What's inside
- From recursion to a table
- Five decisions
- Choosing the order
- Top-down or bottom-up?
- The same idea on any acyclic graph
- Reading a table
- Pseudocode & Multi-Language Implementations (C++, Java, Python)
- Complexity Derivation, Edge Cases & Common Mistakes
03 · Practice
Asked in interviews
Something wrong with this lesson? Report a problem