Skip to main content

Menu

LEVEL 0
0/5 XP
HomeAboutTopicsPricingMy VaultStats

Categories

πŸ€– Artificial Intelligence
☁️ Cloud and Infrastructure
πŸ’Ύ Data and Databases
πŸ’Ό Professional Skills
🎯 Programming and Development
πŸ”’ Security and Networking
πŸ“š Specialized Topics
HomeAboutTopicsPricingMy VaultStats
LEVEL 0
0/5 XP
GitHub
Β© 2026 CheatGridβ„’. All rights reserved.
Privacy PolicyTerms of UseAboutContact

Dynamic Programming Cheat Sheet

Dynamic Programming Cheat Sheet

Back to Mathematics and Algorithms
Updated 2026-04-29
Next Topic: Fourier Analysis and Fast Fourier Transform Cheat Sheet

Dynamic Programming (DP) is an algorithmic optimization technique that solves complex problems by breaking them into overlapping subproblems, storing their solutions to avoid redundant computation. Developed by Richard Bellman in the 1950s, DP applies to problems exhibiting optimal substructure (where optimal solutions contain optimal sub-solutions) and overlapping subproblems (where the same smaller problems recur multiple times). The key insight is that memoization or tabulation transforms exponential-time recursive algorithms into polynomial-time solutions by trading computation for memory β€” storing intermediate results in a cache or table rather than recalculating them repeatedly. Understanding when and how to apply DP, and recognizing its patterns across knapsack variants, string algorithms, grid traversals, graph algorithms, and tree problems, is essential for solving optimization challenges efficiently.

What This Cheat Sheet Covers

This topic spans 17 focused tables and 121 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.

Table 1: Core PropertiesTable 2: Approaches and ImplementationTable 3: 1D DP PatternsTable 4: 2D DP PatternsTable 5: Knapsack VariantsTable 6: String DP PatternsTable 7: Classic ProblemsTable 8: State Machine DPTable 9: Tree DPTable 10: Interval DPTable 11: Bitmask DPTable 12: Graph DPTable 13: Digit DPTable 14: Advanced TechniquesTable 15: Time and Space ComplexityTable 16: Common PitfallsTable 17: Problem Recognition

Table 1: Core Properties

PropertyExampleDescription
Overlapping subproblems
Fibonacci: fib(5) calls fib(3) twice
β€’ Same smaller problems are solved multiple times in naive recursion
β€’ DP caches results to avoid recomputation.
Optimal substructure
Shortest path: optimal path to C via B uses optimal path to B
Optimal solution contains optimal solutions to its subproblems β€” enables building the global optimum from local optima.
Memoization
memo[n] = compute(n)
Top-down caching: stores results of recursive function calls in a lookup table (dict/map) on first computation.
Tabulation
dp[i] = dp[i-1] + dp[i-2]
β€’ Bottom-up iterative: fills a table starting from base cases, building up to the final solution
β€’ no recursion overhead.

More in Mathematics and Algorithms

  • Divide and Conquer Algorithms Cheat Sheet
  • Fourier Analysis and Fast Fourier Transform Cheat Sheet
  • Abstract Algebra Essentials Cheat Sheet
  • Complex Analysis Cheat Sheet
  • Hash Tables and Hash Maps Cheat Sheet
  • Number Theory Cheat Sheet
View all 57 topics in Mathematics and Algorithms