0% found this document useful (0 votes)
7 views8 pages

Dynamic-Programming - PPTX 20241230 132508 0000

Uploaded by

nuthan057
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views8 pages

Dynamic-Programming - PPTX 20241230 132508 0000

Uploaded by

nuthan057
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Dynamic

Programming
Dynamic programming is a powerful problem-solving technique used in
computer science and mathematics. It involves breaking down complex
problems into smaller, overlapping subproblems. This approach allows for
efficient solutions by storing intermediate results, preventing redundant
calculations and improving performance.

By Nuthan M
Defining Dynamic
Programming
Dynamic programming is a method for solving complex The solutions to these subproblems are then combined to form
problems by breaking them down into smaller, overlapping the solution to the original problem. This approach is
subproblems. This involves storing the solutions to these particularly useful for optimization problems, where the goal is
subproblems in a table or array, to avoid recalculating them to find the best solution among a set of possible solutions.
later.
Characteristics of Dynamic
Programming Problems

1 Optimal 2 Overlapping 3 Memoization or


Substructure
The optimal solution to the
Subproblems Tabulation
problem can be constructed from The same subproblems are Solutions to subproblems are
optimal solutions to subproblems. encountered repeatedly while stored to avoid recalculating them.
solving the larger problem.
Solving Problems with
Memoization
Store
1
Results

Check if Result
2 Exists
If the result is already calculated, retrieve it. Otherwise, calculate it and
store it for future use.

Calculate Result
3 Recursive function calls are made to subproblems. The
solutions are combined to form the final solution.
Solving Problems with
Tabulation
Build a Table
1
Create a table to store solutions to subproblems.

Fill the Table


2 Iteratively fill the table from the bottom up, using solutions to smaller subproblems
to calculate solutions to larger subproblems.

Read the Solution


3
The final solution is read from the table.
Common Dynamic
Programming
Algorithms
Fibonacci Knapsack
Sequence
Calculate the nth Fibonacci number. Problem
Maximize the value of items that can
be put in a knapsack with a limited
weight capacity.

Edit Distance Longest Common


Find the minimum number of Subsequence
operations required to transform one Find the longest subsequence
string into another. common to two strings.
Implementing Dynamic
Programming in Code

1 2
Define a Table Fill the Table
Create a table to store the results of Iteratively fill the table, using solutions to
subproblems. smaller subproblems to calculate
solutions to larger subproblems.

3
Return the
Solution
Return the solution from the table.
Conclusion and Key
Takeaways
Dynamic programming is a powerful technique for solving complex problems
efficiently. It involves breaking down problems into smaller subproblems and
storing solutions to avoid redundant calculations. This approach improves
performance and is particularly effective for optimization problems. By
understanding the characteristics and methods of dynamic programming,
you can tackle a wide range of problems in computer science and other
fields.

You might also like