Tricki
a repository of mathematical know-how
Add article
Navigate
Tags
Search
Forums
Help
Top level
›
What kind of problem am I trying to solve?
›
Finding algorithms front page
View
Edit
Revisions
When exhaustive search takes too long and a greedy algorithm is not optimal, consider Dynamic Programming
Title:
*
Area of mathematics:
*
A comma-separated list of areas of mathematics to which this article applies. Use ">" to tag in a subcategory. Example: Analysis > Harmonic analysis, Combinatorics
Keywords:
A comma-separated list of keywords associated with this article. Example: free group
Used in:
A comma-separated list of examples of where this technique is used. Example: Cauchy-Schwarz inequality
Parent articles:
Order
-1
0
1
-1
0
1
Body:
[QUICK DESCRIPTION] Dynamic programming is a "smart exhaust," and is often used to find examples in the case where a greedy algorithm does not return an optimal result. In this article, we describe the criteria needed for a problem to posses a dynamic programming (DP) solution. We also give the general algorithm. [PREREQUISITES] None [EXAMPLE] The basic example of a problem which admits a DP solution is that of finding minimal weight paths of a fixed length between vertices of a weighted, undirected graph $G$ on vertices $\left\{1, ..., n\right\}$. If we write the weight between vertex $i$ and $j$ as $w_{i,j}$, we can collect the weights into a matrix $W = \left(w_{i,j}\right)$. Let $m^{(t)}_{i,j}$ denote the minimal weight path of length $t$ starting at vertex $i$ and ending at vertex $j$. Then we have the recurrence [math weight_recurrence] m^{(t+1)}_{i,j} = \min_{k} w_{k,j} + m^{(t)}_{i,k}.[/math] Here we have written path weight additively. This suggests an algorithm to determine the minimal weight paths between any two vertices: [frame] * Initialize $M^{(1)} = W$ * for $t=1, 2, ..., T-1$ do ** Determine $M^{(t+1)}$ by [eqref weight_recurrence]. [/frame] At termination, $M^{(T)}$ contains the weights of the minimal weight paths of length $T$ between any pair of vertices. Determining the actual paths is done in a similar manner, essentially replacing $\min$ with argmin in [eqref weight_recurrence]. This algorithm runs in $\mathcal O(Tn^2)$ time and $\mathcal O(n^2)$ space. [GENERAL DISCUSSION] [remark] The recurrence relation [eqref weight_recurrence] is just matrix multiplication formula over the $(\min, +)$ semiring (sometimes called the ''tropical semiring''). This implies that $M^{(T)} = W^T$ over that semiring. [/remark]
This is a stub
A stub is an article that is not sufficiently complete to be interesting.
Notifications
File attachments
Changes made to the attachments are not permanent until you save this post. The first "listed" file will be included in RSS feeds.
Attach new file:
Images are larger than
640x480
will be resized. The maximum upload size is
1 MB
. Only files with the following extensions may be uploaded:
jpg jpeg gif png svg
.
Revision information
Log message:
An explanation of the additions or updates being made to help other authors understand your motivations.
Search this site:
Recent articles
View a list of all articles.
Littlewood-Paley heuristic for derivative
Geometric view of Hölder's inequality
Diagonal arguments
Finding an interval for rational numbers with a high denominator
Try to prove a stronger result
Use self-similarity to get a limit from an inferior or superior limit.
Prove a consequence first
Active forum topics
Plenty of LaTeX errors
Tutorial
A different kind of article?
Countable but impredicative
Tricki Papers
more
Recent comments
I don't think this statement
choice of the field
Incorrect Image
Article classification
Higher dimensional analogues
more