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:
- Characterize the structure of an optimal solution.
- Recursively define the value of an optimal solution.
- Compute the value of an optimal solution, typically in a bottom-up fashion.
- Construct an optimal solution from computed information.
-
LIS - Longest Increasing Subsequence
-
LCS - Longest Common Subsequence
- https://leetcode.com/problems/longest-common-subsequence/
- https://infoarena.ro/problema/cmlsc
- https://ideone.com/6EcvVr
- https://ideone.com/sfThv1
- https://ideone.com/kf02K5
- https://ideone.com/Cr2Kat for int arr1[], int arr2[]
- https://ideone.com/tv5Ms7 for string word1, string word2
-
TP - Triangle Problem
-
MSS - Maximum Subsequence Sum
-
Knapsack Discret Problem.
-
Matrix Chain Multiplication
-
Levenshtein Distance
-
Match Words.
-
Finding Comb(n,k)
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
https://www.cs.princeton.edu/courses/archive/spring21/cos226/lectures/DynamicProgramming.pdf
https://www.cs.ox.ac.uk/files/13359/dynamic.pdf
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