Skip to content
← All questions

How can I tell whether a problem can be solved with dynamic programming?

To determine if a problem can be solved with dynamic programming, first try to solve the problem recursively. Then check whether divide-and-conquer style decomposition works, and whether breaking the problem down to the simplest subproblem can eventually build up to the optimal solution. If this can be done, the problem can be solved with dynamic programming.

Conditions

  • You are trying to decide whether a problem is suitable for dynamic programming.

Reasoning, step by step

  1. Try to solve the problem recursively.
  2. Check whether divide-and-conquer style decomposition works.
  3. See if breaking the problem down to the simplest subproblem can eventually build up to the optimal solution.
  4. Conclude that if this can be done, the problem can be solved with dynamic programming.

Example

The video provides a practical test for recognizing DP problems based on recursion and divide-and-conquer.

Common misconceptions

  • Assuming that all recursive problems can be solved with dynamic programming.
  • Confusing the practical test with the formal definition of dynamic programming.

Watch the explanation

Explore next

Answers are generated from source material and independently checked. Consult the original video or creator if something is unclear.