Dynamic Programming Patterns

Dynamic Programming
fib(n) = fib(n-1) + fib(n-2) for n > 1


Characteristics of Dynamic Programming

1. Overlapping Subproblems


2. Optimal Substructure Property


Methods to Solve Dynamic Programming Problem
1. Recursion + Memoization (Top-Down Approach)
2. Iteration + Tabulation (Bottom-Up Approach)

Notes :-

  • Both Tabulated and Memoized store the solutions of subproblems.
  • In Memoized version, table is filled on demand but in Tabulated version, starting from the first entry, all entries are filled one by one.
  • Unlike the Tabulated version, all entries of the lookup table are not necessarily filled in Memoized version.
  • Example:- Memoized solutionof the LCS problem doesn’t necessarily fill all entries.



Patterns to be studied:

  1. Fibonacci Numbers Pattern
  2. 0/1 Knapsack Pattern
  3. Unbounded Knapsack Pattern
  4. Palindromic Subsequence Pattern
  5. Longest Common Substring Pattern




Next: Fibonacci Numbers Pattern →