Sie sind auf Seite 1von 15

Dynamic Programming

By Hazrat Ali

12/27/2019 1
Agenda
• Overview of the Title
• Optimization Problem
• When to use DP
• How to use DP
• Steps for designing DP
• Application of DP

12/27/2019 2
overview
• Dynamic Programming is Strategy for
designing Efficient Algorithms by
considering Time and Space
complexity.
• It is the magic way of reducing the
consumption of computational efforts
of a computer.
• It is the easiest way for solving the
optimization problems.

12/27/2019 3
Optimization Problem
• In optimization problem there are
many solution to the problem.
• But we try to find the optimal value to
solve the problem.
• We use optimal substructure to find the
optimize solution to the problem.

12/27/2019 4
Optimal Substructure
• Optimal substructure means that break
a problem down in simpler, smaller
and similar chunks.
• Then Find the solution of each chunk.
• Find the overlapping in the solutions of
chunks.
• And finally Group the similar solutions.

12/27/2019 5
When to use Dynamic
Programing
• When the problem is breakable into
recurring small problems.
• When there is overlapping in sub
problems.
• When you are going to compute the
same thing again and again the DP
may be use.
• Finally when there is optimal
substructure of the problem.
12/27/2019 6
How to use Dynamic
Programming
• Take the simplest instance of the give
problem.
• Break the instance in small
subproblems that have the same
structure.
• Chose the optimal solution of the
subproblem.
• Find overlapping while solving the
subproblems.
12/27/2019 7
Steps for Designing Dynamic
Program
• breaks the original problem into simple
subproblems.
• Find the optimal solution ‘sol ‘ to the
subproblems.
• Store the result of the subproblem .
(memorization)
• Reuse the result of the subproblem so
that the subproblem is not repeatedly
calculated.
12/27/2019 8
Application of DP
DP is widely used in we need to respond
to a loop effectively.
• Matrix chain Multiplication
• Optimal binary Search tree
• All pairs shortest path
• Reliability design

12/27/2019 9
Normal Fibonacci numbers
program

12/27/2019 10
Output of the Program

12/27/2019 11
Dynamic Fibonacci numbers
program

12/27/2019 12
Output of the program

12/27/2019 13
Keep it all together
• The main rule of dynamic
programming is that do not think
about the space.
• But think of the time.
• Dynamic programming guarantee to
find the optimal solution to a problem
if it exists.

12/27/2019 14
Thank You

12/27/2019 15

Das könnte Ihnen auch gefallen