15 Dynamic Programming
15 Dynamic Programming
Tech
Course Code: AIML303/AIDS303/IOT303
Course Name: Design & Analysis of Algorithms
Dynamic Programming
By:
Dr. Monika Bansal
What is Dynamic Programming?
1. Optimal Substructure:
• A problem exhibits optimal substructure if the solution to the problem
can be constructed efficiently from the solutions of its subproblems. i.e.,
best solution can be built from the best solutions to subproblems.
2. Overlapping Subproblems:
• Dynamic programming is used when the same subproblems are solved
multiple times.
Note: Steps 1-3 form the basis of a DP solution, and step 4 can be omitted if only
the value of an optimal solution is required.
Comparison with Divide and Conquer
•Dynamic Programming:
• Suitable for problems with overlapping subproblems.
• Uses memoization or tabulation to store intermediate
results.
•Divide and Conquer:
• Breaks problems into independent subproblems.
• Does not reuse subproblems, hence no need for
memoization.