I knew this was an old post, but I had the same questions, so I answer myself here.
Dynamic programming has two properties:
- Optimal substructure : A globally optimal solution can be found by combining optimal solutions with local subtasks. For example, fib (x) = fib (x - 1) + fib (x - 2)
- Overlapping subtasks : finding the best solution involves solving the same problem several times. For example, calculate fib (x) many times in a Fibonocci sequence
In accordance with the above definitions / properties, it is unclear whether questions such as “Does the element have a set” are asked? or “How to find the amount of a set” can be classified as dynamic programming? I can split the set into a subset (resolve globally) and add it (get a global response). In addition, in the subset, I did the summation many times.
I found a paragraph in the book, and I think it gives very useful tips to distinguish between Dynamic Programming (DP) and Split Algorithm and Overcome (D&C).
In the D&C subtasks, they are significantly smaller than the original task. In contrast, DP involves solving problems that are only slightly smaller than the original problem. For example, calculating Fib (19) is not a substantially smaller problem than computing Fib (20). Although the sum of the calculations of ten elements is significantly less than the sum of ten million elements.
The efficiency of D & C algorithms does not depend on the structure of the algorithm, so that identical tasks are solved repeatedly. In contrast, DP is only effective when the number of individual subtasks is significantly less than the total number of subtasks.
source share