I assume Dynamic Programming can be used only when the corresponding subproblems form a Directed Acyclic Graph, otherwise you're stuck in a loop.

Is this reasoning correct or is there more to it?

  • $\begingroup$ Have you tried stating every step of the claim formally? You might be able to dive deeper into your own question. You can then probably answer your own question. $\endgroup$
    – John L.
    Jan 7 '19 at 13:14

Let $V_P(n)$ represent the value of the optimal solution to a problem $P$ with size $n$. According to Bellman equations, this value is computed from the value of the optimal solutions of its subproblems $P'$: $V_P(n) = \oplus \{v_{P'} + V_{P'}(n')\}$ where $\oplus$ is an operator such as $\max$, $\min$, +, ... $v_{P'}$ is an operator which steps from $P$ to $P'$, and $P'$ are the subproblems of $P$ with size $n'$ which is always strictly less than $n$, the size of the original problem.

From here, it seems affordable to create a graph $G(V,E)$ where $V$ are the values of the optimal solutions of different problems, and there is an edge between two vertices $u$ and $v$ if and only if $v$ represents a problem $P'$ which is acknowledged as a subproblem of task $P$ represented by vertex $u$. For example, when using Dynamic Programming for computing the Fibonacci numbers, if $u$ represents $Fib(n)$, then there are two edges from it to other vertices representing $Fib(n-1)$ and $Fib(n-2)$.

If this is the graph you meant in your question then, clearly, the resulting graph is a Directed Acyclic Graph because:

  1. Each vertex is directed in only one direction: from $u$ to $v$ as only one problem ($P'$) can be a subproblem of another, $P$.
  2. It is impossible to form a loop as $n'<n$.

All this said, however, I do not think that this characterization is too useful as it also applies to other techniques such as Divide and Conquer and plain recursion. As you are asking whethere there is more about it or not, let me highlight that an important issue to consider when deciding whether to use Dynamic Programming or not, is if the problem $P$ shows suboptimal structure, see this definition in the second paragraph.

Hope this helps,


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.