Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Dynamic Programming

Dynamic Programming, like the divide-and-conquer method, solves problemes by combining the solutions to subproblems. "Programming" in this context refers to a tabular method, not to writing computer code. As we saw in DivideEtImpera algorithms partion the problem into dijoint subproblems, solve the subproblems recursively, and then combine their solutions to solve the original problem. In contrast, dynamic programming applies when the subproblems overlap-that is, when subproblems share subsubproblems. In this context, a divideEtImpera algorithm does more work than necessary, repeatedly solving the common subsubproblems. A dynamic programming algorithm solves each subsubproblem just once and then saves its answer in a table, thereby avoiding the work of recomputing the answer every time it solves each subsubproblem.

We typically apply dynamic programming to optimization problems. Such problems can have many possible solutions. Each solution has a value, and we wish to find a solution with the optimal (minimum or maximum) value. We call such a solution an optimal solution to the problem, as opposed to the optimal solution, since there may be several solutions that achive the optimal value.

When developing a dynamic programming algorithm, we follow a sequence of four steps:

  1. Characterize the structure of an optimal solution.
  2. Recursively define the value of an optimal solution.
  3. Compute the value of an optimal solution, typically in a bottom-up fashion.
  4. Construct an optimal solution from computed information.

Practice

  1. LIS - Longest Increasing Subsequence

  2. LCS - Longest Common Subsequence

  3. TP - Triangle Problem

  4. MSS - Maximum Subsequence Sum

  5. Knapsack Discret Problem.

  6. Matrix Chain Multiplication

  7. Levenshtein Distance

  8. Match Words.

  9. Finding Comb(n,k)

Problem Set

https://leetcode.com/tag/dynamic-programming/

https://leetcode.com/problems/best-time-to-buy-and-sell-stock/description/

https://www.pbinfo.ro/probleme/categorii/158/programare-dinamica-probleme-de-numarare

https://www.pbinfo.ro/probleme/categorii/53/programare-dinamica

https://cses.fi/problemset/task/1639/

https://cses.fi/problemset/task/1145

https://www.infoarena.ro/problema/rucsac

https://www.pbinfo.ro/probleme/1886/rucsac1

https://www.pbinfo.ro/probleme/4439/limbajformal

https://www.pbinfo.ro/probleme/4576/bilbob

References

https://www.cs.princeton.edu/courses/archive/spring21/cos226/lectures/DynamicProgramming.pdf

https://www.cs.ox.ac.uk/files/13359/dynamic.pdf

https://www.infoarena.ro/pd

https://www.pbinfo.ro/articole/17951/programare-dinamica-introducere

https://www.programiz.com/dsa/longest-common-subsequence

https://ocw.cs.pub.ro/courses/pa/laboratoare/laborator-03

https://web.stanford.edu/class/cs124/lec/med.pdf

https://usaco.guide/gold/intro-dp?lang=cpp

https://usaco.guide/gold/lis?lang=cpp

Ideone

https://ideone.com/thinkphp/dynamicprogramming