Dynamic Programming :
Dynamic programming is a technique for solving problems by breaking them down into smaller subproblems, solving each subproblem once, and storing the solution to each subproblem so that it can be reused in the future. Some characteristics of dynamic programming include:
Optimal substructure: Dynamic programming problems typically have an optimal substructure, meaning that the optimal solution to the problem can be obtained by solving the subproblems optimally and combining their solutions.
Overlapping subproblems: Dynamic programming problems often involve overlapping subproblems, meaning that the same subproblems are solved multiple times. To avoid solving the same subproblem multiple times, dynamic programming algorithms store the solutions to the subproblems in a table or array, so that they can be reused later.
Bottom-up approach: Dynamic programming algorithms usually solve problems using a bottom-up approach, meaning that they start by solving the smallest subproblems and work their way up to the larger ones.
Efficiency: Dynamic programming algorithms can be very efficient, especially when the subproblems overlap significantly. By storing the solutions to the subproblems and reusing them, dynamic programming algorithms can avoid redundant computations and achieve good time and space complexity.
Applicability: Dynamic programming is applicable to a wide range of problems, including optimization problems, decision problems, and problems that involve sequential decisions. It is often used to solve problems in computer science, operations research, and economics.
Algorithm Design Techniques
Iterative techniques, Divide and Conquer, Dynamic Programming, Greedy Algorithms.
1. Presentation
on
By
BHARAT BHUSHAN
Asst. Professor, Department of Computer Sc.
RLSY College, Ranchi
Buddha Science and Technical Institute, Ranchi
www.bharatsir.com
Dynamic Programming in
Algorithm Design Technique
2. www.bharatsir.com || Mo No : 09835376044 || WhtasApp : 09006365889
Algorithm Design
Dynamic Programming
Dynamic Programming (DP) is an algorithmic
technique for solving an optimization problem by
breaking it down into simpler sub problems and
utilizing the fact that the optimal solution to the
overall problem depends upon the optimal solution
to its sub problems.
Dynamic programming approach is similar to divide
and conquer in breaking down the problem into
smaller and yet smaller possible sub-problems. But
unlike, divide and conquer, these sub-problems are
not solved independently.
3. www.bharatsir.com || Mo No : 09835376044 || WhtasApp : 09006365889
Algorithm Design
Dynamic Programming Approach Work
The following are the steps that the dynamic
programming follows:
It breaks down the complex problem into simpler
sub problems.
It finds the optimal solution to these sub-problems.
It stores the results of sub problems.
The process of storing the results of sub problems
is known as memorization.
It reuses them so that same sub-problem is
calculated more than once.
Finally, calculate the result of the complex
problem.
4. www.bharatsir.com || Mo No : 09835376044 || WhtasApp : 09006365889
Algorithm Design
Approaches of Dynamic Programming
There are two approaches to dynamic programming:
Top-down approach
Bottom-up approach
Top-down approach : The top-down method
solves the overall problem before you break it
down into sub problems. This process works to
solve larger problems by finding the solution to
sub problems recursively, caching each result.
5. www.bharatsir.com || Mo No : 09835376044 || WhtasApp : 09006365889
Algorithm Design
Approaches of Dynamic Programming
Bottom-up approach : The bottom-up approach is
also one of the techniques which can be used to
implement the dynamic programming. It uses the
tabulation technique to implement the dynamic
programming approach. It solves the same kind of
problems but it removes the recursion.
If we remove the recursion, there is no stack
overflow issue and no overhead of the recursive
functions. In this tabulation technique, we solve
the problems and store the results in a matrix.
6. www.bharatsir.com || Mo No : 09835376044 || WhtasApp : 09006365889
Algorithm Design
Examples
The following computer problems can be solved
using dynamic programming approach −
Fibonacci number series
Knapsack problem
Tower of Hanoi
All pair shortest path by Floyd-Warshall
Shortest path by Dijkstra
Project scheduling
7. www.bharatsir.com || Mo No : 09835376044 || WhtasApp : 09006365889
Algorithm Design
Advantages of Dynamic Programming
1. Dynamic programming can be used to obtain
local as well as the total optimal solution.
2. Dynamic programming algorithms are
generally compact code pieces as they are
based on recursive functions.
3. The linear and non-linear problem, both kind
of problems can be solved using dynamic
programming.
4. Dynamic programming algorithms are easy to
debug.
8. www.bharatsir.com || Mo No : 09835376044 || WhtasApp : 09006365889
Algorithm Design
Disadvantages of Dynamic Programming
1. Dynamic programming uses recursion, which
requires more memory in the call stack, and
leads to a stack overflow condition in the
runtime.
2. It takes memory to store the solutions of each
sub-problem. There is no guarantee that the
stored value will be used later in execution.