SlideShare a Scribd company logo
DYNAMIC PROGRAMMING
•Presented By Group : 4
•Group Members :
•Md.Nazmus Shakib -220320852
•Tanvin Sadik Dhrubo -220320860
•Khan Waziur Rahman -220320861
•Arghya Saha -200120456
INTRODUCTION TO
DYNAMIC PROGRAMMING
• Dynamic Programming is a method for
solving complex problems by breaking
them down into simpler sub problems. It is
applicable where the problem can be
divided into overlapping subproblems and
has optimal substructure. It is also known
as divide and conquer technique
Why We Choose Dynamic Programming Over Greedy
Method?
Dynamic programming (DP) is often preferred over the greedy method for solving
optimization problems where future decisions are affected by earlier ones. In
greedy algorithms, the approach is to make the locally optimal choice at each stage
in hopes of finding the global optimum. However, this doesn't always lead to the
best solution for all problems, as greedy methods may miss key subproblems or fail
to consider how earlier decisions affect the later ones.
DYNAMIC
PROGRAMMING
APPROACHES
Top Down(Memoization):
Starts By Solving Main Problems & Breaks It
down Into Smaller Parts
Saves The Answers To These Smaller Parts In A
Table To Avoid Doing The Same Work Twice
Works Well When There Are Smaller Parts
DYNAMIC PROGRAMMING APPROACHES
Bottom-Up(Tabulation):
Begins by solving the smallest parts of the problem first
Uses these small solutions to build up the final answer step by step
Works well when there are fewer smaller parts,& the final answer can be easily
found by using these smaller solutions
MEMOIZATION VS TABULATION
Memoization:Top-
down approach.
Uses recursion.
Stores results of
subproblems as
they are solved
Tabulation:Bottom-
up approach.
Iterative solution.
Builds solutions to
all subproblems and
uses them
MEMOIZATION
F4
F2
F1 F0
F1 F1 F0
F2
F3
0 1 1 2 3
F0 F1 F2 F3 F4
F =
Time Complexity= O(n)
Fn
F(n-2)
F(n-1)
Global Array
MEMOIZATION
The Fibonacci sequence is defined as:
F(n)=F(n−1)+F(n−2)
with base cases:
F(0)=0, F(1)=1
Function Of fibonacci series :
int fib(int n){
if (n<=1) {
return n;
} else {
return fib(n-2) + fib(n-
1);
}
Top-down approach
TABULATION
Function Of fibonacci series:
int fib(int n){
if (n<=1) {
return n;
F[0]=0;F[1]=1;
}
for(int i=2; i<=n; i++){
F[i] = F[i-2]+F[i-1];
}
return F[n];
}
0 1 1 2 3
F0 F1 F2 F3 F4
F =
Time Complexity= O(n)
Global Array
Bottom-up
approach
F1 F0
F2
KEY CONCEPTS OF DYNAMIC
PROGRAMMING
Optimal Substructure: The optimal
solution to the problem can be
constructed from the optimal solutions of
its subproblems.
Overlapping Subproblems:
Subproblems are reused multiple
times.
STEPS TO APPLY DYNAMIC PROGRAMMING
Define
Define the
subproblems.
Identify
Identify the
recursive
relation.
Choose
Choose
between
memoization
or tabulation.
Solve
Solve the base
cases.
Build
Build the
solution from
subproblem
results.
ADVANTAGES OF DYNAMIC
PROGRAMMING
EFFICIENT FOR SOLVING
OPTIMIZATION PROBLEMS.
REDUCES TIME COMPLEXITY BY
STORING INTERMEDIATE
RESULTS.
HELPS AVOID REDUNDANT
CALCULATIONS.
DISADVANTAGES
May require a lot of memory.
Requires identifying overlapping
subproblems and optimal substructure,
which may not be straightforward
THANK YOU!

More Related Content

PPTX
Dynamic programming in Design Analysis and Algorithms
PDF
L21_L27_Unit_5_Dynamic_Programming Computer Science
PPTX
ADA Unit 2.pptx
PDF
Dynamic Programming Algorithm CSI-504.pdf
PPTX
Dynamic_Programming_Presentation in Design and Analysis of Algorithm
PPTX
Dynamic Programing.pptx good for understanding
PPTX
dinosourrrrrrrrrrrrrrrrrrrrrr formula .pptx
PPTX
Algorithm Design Technique
Dynamic programming in Design Analysis and Algorithms
L21_L27_Unit_5_Dynamic_Programming Computer Science
ADA Unit 2.pptx
Dynamic Programming Algorithm CSI-504.pdf
Dynamic_Programming_Presentation in Design and Analysis of Algorithm
Dynamic Programing.pptx good for understanding
dinosourrrrrrrrrrrrrrrrrrrrrr formula .pptx
Algorithm Design Technique

Similar to DYNAMIC_________________________PROGRAMMING.pptx (20)

PDF
Dynamic Programming
PPTX
Introduction to Dynamic Programming, Principle of Optimality
PPTX
Computer science in Dynamic programming .pptx
PPTX
Introduction to dynamic programming
PDF
Dynamic programming
PDF
Unit 4 of design and analysis of algorithms
PPTX
Module 2ppt.pptx divid and conquer method
PPTX
Dynamic Programming: Optimizing Solutions
PPTX
Algorithm_Dynamic Programming
PPTX
Dynamic Programming
PPTX
Dynamic programming
PPT
dynamic-programming unit 3 power point presentation
PPTX
Elements of Dynamic Programming
PPTX
Dynamic programming class 16
PPTX
Dynamic Programming.pptx
PPTX
Annotaed slides for dynamic programming algorithm
PPTX
esign and Analysis of Algorithms Presentation.pptx
PPT
Pintu ram
PPT
Dynamic programming 2
PPTX
Dynamic programmng2
Dynamic Programming
Introduction to Dynamic Programming, Principle of Optimality
Computer science in Dynamic programming .pptx
Introduction to dynamic programming
Dynamic programming
Unit 4 of design and analysis of algorithms
Module 2ppt.pptx divid and conquer method
Dynamic Programming: Optimizing Solutions
Algorithm_Dynamic Programming
Dynamic Programming
Dynamic programming
dynamic-programming unit 3 power point presentation
Elements of Dynamic Programming
Dynamic programming class 16
Dynamic Programming.pptx
Annotaed slides for dynamic programming algorithm
esign and Analysis of Algorithms Presentation.pptx
Pintu ram
Dynamic programming 2
Dynamic programmng2
Ad

Recently uploaded (20)

PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
RMMM.pdf make it easy to upload and study
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
master seminar digital applications in india
PDF
Trump Administration's workforce development strategy
PPTX
Pharma ospi slides which help in ospi learning
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
PDF
01-Introduction-to-Information-Management.pdf
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
A systematic review of self-coping strategies used by university students to ...
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PPTX
Lesson notes of climatology university.
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
Weekly quiz Compilation Jan -July 25.pdf
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
human mycosis Human fungal infections are called human mycosis..pptx
Abdominal Access Techniques with Prof. Dr. R K Mishra
Supply Chain Operations Speaking Notes -ICLT Program
RMMM.pdf make it easy to upload and study
O7-L3 Supply Chain Operations - ICLT Program
master seminar digital applications in india
Trump Administration's workforce development strategy
Pharma ospi slides which help in ospi learning
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
01-Introduction-to-Information-Management.pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
A systematic review of self-coping strategies used by university students to ...
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Lesson notes of climatology university.
2.FourierTransform-ShortQuestionswithAnswers.pdf
Weekly quiz Compilation Jan -July 25.pdf
Ad

DYNAMIC_________________________PROGRAMMING.pptx

  • 1. DYNAMIC PROGRAMMING •Presented By Group : 4 •Group Members : •Md.Nazmus Shakib -220320852 •Tanvin Sadik Dhrubo -220320860 •Khan Waziur Rahman -220320861 •Arghya Saha -200120456
  • 2. INTRODUCTION TO DYNAMIC PROGRAMMING • Dynamic Programming is a method for solving complex problems by breaking them down into simpler sub problems. It is applicable where the problem can be divided into overlapping subproblems and has optimal substructure. It is also known as divide and conquer technique
  • 3. Why We Choose Dynamic Programming Over Greedy Method? Dynamic programming (DP) is often preferred over the greedy method for solving optimization problems where future decisions are affected by earlier ones. In greedy algorithms, the approach is to make the locally optimal choice at each stage in hopes of finding the global optimum. However, this doesn't always lead to the best solution for all problems, as greedy methods may miss key subproblems or fail to consider how earlier decisions affect the later ones.
  • 4. DYNAMIC PROGRAMMING APPROACHES Top Down(Memoization): Starts By Solving Main Problems & Breaks It down Into Smaller Parts Saves The Answers To These Smaller Parts In A Table To Avoid Doing The Same Work Twice Works Well When There Are Smaller Parts
  • 5. DYNAMIC PROGRAMMING APPROACHES Bottom-Up(Tabulation): Begins by solving the smallest parts of the problem first Uses these small solutions to build up the final answer step by step Works well when there are fewer smaller parts,& the final answer can be easily found by using these smaller solutions
  • 6. MEMOIZATION VS TABULATION Memoization:Top- down approach. Uses recursion. Stores results of subproblems as they are solved Tabulation:Bottom- up approach. Iterative solution. Builds solutions to all subproblems and uses them
  • 7. MEMOIZATION F4 F2 F1 F0 F1 F1 F0 F2 F3 0 1 1 2 3 F0 F1 F2 F3 F4 F = Time Complexity= O(n) Fn F(n-2) F(n-1) Global Array
  • 8. MEMOIZATION The Fibonacci sequence is defined as: F(n)=F(n−1)+F(n−2) with base cases: F(0)=0, F(1)=1 Function Of fibonacci series : int fib(int n){ if (n<=1) { return n; } else { return fib(n-2) + fib(n- 1); } Top-down approach
  • 9. TABULATION Function Of fibonacci series: int fib(int n){ if (n<=1) { return n; F[0]=0;F[1]=1; } for(int i=2; i<=n; i++){ F[i] = F[i-2]+F[i-1]; } return F[n]; } 0 1 1 2 3 F0 F1 F2 F3 F4 F = Time Complexity= O(n) Global Array Bottom-up approach F1 F0 F2
  • 10. KEY CONCEPTS OF DYNAMIC PROGRAMMING Optimal Substructure: The optimal solution to the problem can be constructed from the optimal solutions of its subproblems. Overlapping Subproblems: Subproblems are reused multiple times.
  • 11. STEPS TO APPLY DYNAMIC PROGRAMMING Define Define the subproblems. Identify Identify the recursive relation. Choose Choose between memoization or tabulation. Solve Solve the base cases. Build Build the solution from subproblem results.
  • 12. ADVANTAGES OF DYNAMIC PROGRAMMING EFFICIENT FOR SOLVING OPTIMIZATION PROBLEMS. REDUCES TIME COMPLEXITY BY STORING INTERMEDIATE RESULTS. HELPS AVOID REDUNDANT CALCULATIONS.
  • 13. DISADVANTAGES May require a lot of memory. Requires identifying overlapping subproblems and optimal substructure, which may not be straightforward