3
$\begingroup$

The usual criteria used to decide if a problem can be solved using dynamic programming is (1) if it has optimal sub-problems and (2) if it has overlapping sub-problems. Does the word "optimal" mean that DP can only be used to solve optimization problems? Otherwise, it would make more sense to write (1) as "if it can be decomposed in sub-problems" (i.e. it is recursive). Obviously, this definition includes optimization problems with optimal sub-problems.

$\endgroup$
  • $\begingroup$ Here is an example of a decision problem amenable to dynamic programming: is the edit distance between $x,y$ at most $d$? $\endgroup$ – Yuval Filmus Dec 2 '19 at 14:56
  • 1
    $\begingroup$ Problems involving counting something (e.g., the number of ways of building a $3\times n$ wall out of dominos) can often be solved with what I'd call dynamic programming. More discussion here: cs.stackexchange.com/questions/79664/… $\endgroup$ – j_random_hacker Dec 3 '19 at 0:49
  • $\begingroup$ I wonder if problems "count ways to do X" aren't always equivalent to "find quantity optimizing Y". I can't think of Y for say, Fibonacci numbers, but that's not the same as saying no one can. $\endgroup$ – Matthew C Dec 6 '19 at 16:40
6
$\begingroup$

Dynamic Programming can be used to solve a problem as long as the problem has a recursive substructure and the sub-structural problems are overlapping. So, as long as a problem has the two properties, DP can be used for solving it. Problems with these properties are definitely not restricted to only optimization problems. So, yes.

Here are some good examples of non-optimization problems which can be solved quickly using DP:

  1. Coin Change Problem

  2. Counting the number of increasing subsequences in a given sequence

  3. If you forget everything, calculating upto the first $n$ Fibonacci Numbers using its recurrence relation can be done using Dynamic Programming.

$\endgroup$
  • $\begingroup$ Great answer, welcome to the site! $\endgroup$ – jmite Dec 6 '19 at 18:12
  • $\begingroup$ Thanks for the appreciation! :D $\endgroup$ – Arkajyoti Banerjee Dec 6 '19 at 18:13

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.