Dynamic Programming
Last updated
Was this helpful?
Last updated
Was this helpful?
In the fields of computer science, economics, managerial sciences, mathematics and bioinformatics, or dynamic optimization is similar to principle as to decompose a complex problem into smaller sub-problems.
In contrast to the paradigm of that sub-problems are independent, dynamic programming is adopted to solve interleaved sub-problems wherein multiple sub-problems might have common smaller sub-problems. And for each repetitive sub-problem, would store and reuse the solution when it was solved the first time (also known as ), programming solutions all together.
The typical algorithm is developed in steps follow:
Characterize the optimal sub-structures along with possible moves. (think of it as finding a DAG for a solution path)
Define the recurrence relations of sub-problems.
Compute recursively or iteratively in a bottom-up fashion or top-down with fashion.
Construct an overall optimal solution or combining solutions of sub-problems.
Noted that the word programming does not stand for computer programming but a tabulation method that was invented by .
It is often confusing to determine if the programming logic is built on or . Both are adopted in favor of tackling optimization problem, and seeks and combines the previous solutions for sub-problems to yield the final result while chooses locally optimal solution in each run and not guarantee to have the optimal result.
For instance, in a of finding a minimum number of coins with certain denominations added up to a specified amount, is a killer solution than using in that:
given a set of denominations: 1, 4, 5, 15, 20 and the specified amount 23; the would yield an optimal solution of 15 + 4 + 4 while the offers a non-optimal one 20 + 1 + 1 + 1.
wherein, picks the largest one in the set of coins from the first run; takes into account the solutions to each small sub-problem that are related to each other during iterations.
The following example questions can be categorized into type:
- a topic referring to that to find a ith such number.
- solving the matrix dot multiplication in an most efficient way by least number of scalar multiplications in total.
- a practical problem found in many scenarios such as DNA sequences detection.
- knapsack problem in a discrete version.