Dynamic Programming versus Memoization
blog.racket-lang.org
Dynamic Programming versus Memoization
1–10 of 29 posts
Re: Dynamic Programming versus Memoization
#2Re: Dynamic Programming versus Memoization
#3I was under the impression that the terms were more or less synonymous.
Re: Dynamic Programming versus Memoization
#4My lack of a formal CS background is hurting me here. Could someone speak to the distinction between a tree and a DAG they make here? I was under the impression that the terms were more or less synonymous.
Re: Dynamic Programming versus Memoization
#5This is a really interesting way to think about computations. I mostly think of memoization for I/O things like database lookups, or long computations. I'd never thought of it in comparison to dynamic programming algorithms.
f(arguments) {
results = memoTable[arguments]
if(results) // use results
else
results = // expensive recursive call to f
memoTable[arguments] = results
}Re: Dynamic Programming versus Memoization
#6Memoization, however, is much more of a black-box. Very few compilers will handle the branching present in memoized function calls in the same way they'd handle a loop (which is also a branch, but a more predictable one).
That all being said, memoization is often simpler to reason about and great for infrequent computations.
Re: Dynamic Programming versus Memoization
#7My lack of a formal CS background is hurting me here. Could someone speak to the distinction between a tree and a DAG they make here? I was under the impression that the terms were more or less synonymous.
A tree is a DAG that is connected: if a and b are nodes of a tree, there is a path between a and b . But in general a DAG doesn't have to be connected. So all trees are DAGs but not all DAGs are trees: some are forests i.e. unions of trees.
A DAG is a directed graph that has no (directed) loops. Consider the following:
A
/ \
v v
B C
\ /
v v
D
This is a DAG but not a tree, because it has an undirected loop but no directed loops.Re: Dynamic Programming versus Memoization
#8My lack of a formal CS background is hurting me here. Could someone speak to the distinction between a tree and a DAG they make here? I was under the impression that the terms were more or less synonymous.
Here's an example of a DAG that can't be a tree because of the edge directions:
http://en.wikipedia.org/wiki/File:Directed_acyclic_graph_3.s...
Re: Dynamic Programming versus Memoization
#9My lack of a formal CS background is hurting me here. Could someone speak to the distinction between a tree and a DAG they make here? I was under the impression that the terms were more or less synonymous.
Re: Dynamic Programming versus Memoization
#10My lack of a formal CS background is hurting me here. Could someone speak to the distinction between a tree and a DAG they make here? I was under the impression that the terms were more or less synonymous.
A tree is a DAG that is connected: if a and b are nodes of a tree, there is a path between a and b . But in general a DAG doesn't have to be connected. So all trees are DAGs but not all DAGs are trees: some are forests i.e. unions of trees.
A tree is a connected undirected acyclic graph (or, equivalently, an undirected graph in which there is exactly one path between any pair of vertices).
A DAG may represent a tree (usually rooted) or it may not. Not all connected DAGs are trees e.g.:
a->b, a->c, b->d, c->d is a DAG, but not a tree.