SlideShare a Scribd company logo
Dynamic Programming
Algorithm
Presented by 602, 629, 630, 646
What is Dynamic
Programming (DP)
Algorithm
Dynamic Programming (DP) is a method
used in mathematics and computer
science to solve complex problems by
breaking them down into simpler
subproblems. By solving each subproblem
only once and storing the results, it avoids
redundant computations, leading to more
efficient solutions for a wide range of
problems.
How does DP
works
• Identify Subproblems: Divide the main
problem into smaller, independent
subproblems.
• Store Solutions: Solve each subproblem
and store the solution in a table or array.
• Build Up Solutions: Use the stored
solutions to build up the solution to the
main problem.
• Avoid Redundancy: By storing solutions,
DP ensures that each subproblem is solved
only once, reducing computation time.
Example of Dynamic Programming (DP)
Example 1: Consider the problem of finding the Fibonacci
sequence:
Fibonacci sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, …
Brute Force Approach:
To find the nth Fibonacci number using a brute force approach, you
would simply add the (n-1)th and (n-2)th Fibonacci numbers. This would
work, but it would be inefficient for large values of n, as it would require
calculating all the previous Fibonacci numbers.
F(0) = 0
F(1) = 1
F(n) = F(n-1) + F(n-2)
Fibonacci Series using Dynamic
Programming
Subproblems: F(0), F(1), F(2), F(3), …
Store Solutions: Create a table to store the values of F(n)
as they are calculated.
Build Up Solutions: For F(n), look up F(n-1) and F(n-2) in
the table and add them.
Avoid Redundancy: The table ensures that each
subproblem (e.g., F(2)) is solved only once.
By using DP, we can efficiently calculate the Fibonacci
sequence without having to recompute subproblems.
Approaches of
Dynamic
Programming (DP)
Dynamic programming can be
achieved using two approaches:
01. Top-Down
Approach
02. Bottom-Down
Approach
Top-Down Approach
In the top-down approach, also known as memoization,
we start with the final solution and recursively break it
down into smaller subproblems. To avoid redundant
calculations, we store the results of solved subproblems
in a memoization table.
Let’s breakdown Top down approach:
• Starts with the final solution and recursively breaks
it down into smaller subproblems.
• Stores the solutions to subproblems in a table to
avoid redundant calculations.
• Suitable when the number of subproblems is large
and many of them are reused.
Bottom-Down Approach
In the bottom-up approach, also known as tabulation,
we start with the smallest subproblems and gradually
build up to the final solution. We store the results of
solved subproblems in a table to avoid redundant
calculations.
Let’s breakdown Bottom-up approach:
• Starts with the smallest subproblems and gradually
builds up to the final solution.
• Fills a table with solutions to subproblems in a
bottom-up manner.
• Suitable when the number of subproblems is small
and the optimal solution can be directly computed
from the solutions to smaller subproblems.
Applications:
Dynamic programming has a wide range of
applications, including:
• Optimization: Knapsack problem,
shortest path problem, maximum
subarray problem
• Computer Science: Longest common
subsequence, edit distance, string
matching
• Operations Research: Inventory
management, scheduling, resource
allocation
Thank you
very much!
Ad

Recommended

Computer science in Dynamic programming .pptx
Computer science in Dynamic programming .pptx
shorabi2127061
 
Dynamic Programing.pptx good for understanding
Dynamic Programing.pptx good for understanding
HUSNAINAHMAD39
 
Dynamic Programming: Optimizing Solutions
Dynamic Programming: Optimizing Solutions
iiillusion23
 
Algorithm Design Technique
Algorithm Design Technique
Bharat Bhushan
 
Dynamic Programming
Dynamic Programming
Bharat Bhushan
 
Module 2ppt.pptx divid and conquer method
Module 2ppt.pptx divid and conquer method
JyoReddy9
 
Dynamic programming 2
Dynamic programming 2
Roy Thomas
 
DYNAMIC_________________________PROGRAMMING.pptx
DYNAMIC_________________________PROGRAMMING.pptx
nazmusshakib335
 
dinosourrrrrrrrrrrrrrrrrrrrrr formula .pptx
dinosourrrrrrrrrrrrrrrrrrrrrr formula .pptx
ShohidulIslamSovon
 
Annotaed slides for dynamic programming algorithm
Annotaed slides for dynamic programming algorithm
johnathangamal27
 
Dynamic programming
Dynamic programming
Yıldırım Tam
 
Dynamic programming
Dynamic programming
Md.Mojibul Hoque
 
Dynamic programming
Dynamic programming
Jay Nagar
 
Presentation (1) (5).pptx in DAA computer
Presentation (1) (5).pptx in DAA computer
MadhurimaKomanduru
 
Presentation (1) (5).pptx in DAA computer
Presentation (1) (5).pptx in DAA computer
MadhurimaKomanduru
 
Introduction to Dynamic Programming, Principle of Optimality
Introduction to Dynamic Programming, Principle of Optimality
Bhavin Darji
 
W8L1 Introduction & Fibonacci Numbers part 1.pptx
W8L1 Introduction & Fibonacci Numbers part 1.pptx
sakibahmed181234
 
Dynamic programming in Design Analysis and Algorithms
Dynamic programming in Design Analysis and Algorithms
NikunjGoyal20
 
Dynamic Programming
Dynamic Programming
paramalways
 
Dynamic Programming.pptx
Dynamic Programming.pptx
MuktarHossain13
 
Pintu ram
Pintu ram
pinturam2
 
Introduction to dynamic programming
Introduction to dynamic programming
Amisha Narsingani
 
Dynamic pgmming
Dynamic pgmming
Dr. C.V. Suresh Babu
 
ADA Unit 2.pptx
ADA Unit 2.pptx
AmanKumar879992
 
Dynamic programming class 16
Dynamic programming class 16
Kumar
 
Dynamic programming Basics
Dynamic programming Basics
Kvishnu Dahatonde
 
L21_L27_Unit_5_Dynamic_Programming Computer Science
L21_L27_Unit_5_Dynamic_Programming Computer Science
priyanshukumarbt23cs
 
Dynamic programming prasintation eaisy
Dynamic programming prasintation eaisy
ahmed51236
 
Chalukyas of Gujrat, Solanki Dynasty NEP.pptx
Chalukyas of Gujrat, Solanki Dynasty NEP.pptx
Dr. Ravi Shankar Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
VCE Literature Section A Exam Response Guide
VCE Literature Section A Exam Response Guide
jpinnuck
 

More Related Content

Similar to Dynamic Programming Algorithm CSI-504.pdf (20)

dinosourrrrrrrrrrrrrrrrrrrrrr formula .pptx
dinosourrrrrrrrrrrrrrrrrrrrrr formula .pptx
ShohidulIslamSovon
 
Annotaed slides for dynamic programming algorithm
Annotaed slides for dynamic programming algorithm
johnathangamal27
 
Dynamic programming
Dynamic programming
Yıldırım Tam
 
Dynamic programming
Dynamic programming
Md.Mojibul Hoque
 
Dynamic programming
Dynamic programming
Jay Nagar
 
Presentation (1) (5).pptx in DAA computer
Presentation (1) (5).pptx in DAA computer
MadhurimaKomanduru
 
Presentation (1) (5).pptx in DAA computer
Presentation (1) (5).pptx in DAA computer
MadhurimaKomanduru
 
Introduction to Dynamic Programming, Principle of Optimality
Introduction to Dynamic Programming, Principle of Optimality
Bhavin Darji
 
W8L1 Introduction & Fibonacci Numbers part 1.pptx
W8L1 Introduction & Fibonacci Numbers part 1.pptx
sakibahmed181234
 
Dynamic programming in Design Analysis and Algorithms
Dynamic programming in Design Analysis and Algorithms
NikunjGoyal20
 
Dynamic Programming
Dynamic Programming
paramalways
 
Dynamic Programming.pptx
Dynamic Programming.pptx
MuktarHossain13
 
Pintu ram
Pintu ram
pinturam2
 
Introduction to dynamic programming
Introduction to dynamic programming
Amisha Narsingani
 
Dynamic pgmming
Dynamic pgmming
Dr. C.V. Suresh Babu
 
ADA Unit 2.pptx
ADA Unit 2.pptx
AmanKumar879992
 
Dynamic programming class 16
Dynamic programming class 16
Kumar
 
Dynamic programming Basics
Dynamic programming Basics
Kvishnu Dahatonde
 
L21_L27_Unit_5_Dynamic_Programming Computer Science
L21_L27_Unit_5_Dynamic_Programming Computer Science
priyanshukumarbt23cs
 
Dynamic programming prasintation eaisy
Dynamic programming prasintation eaisy
ahmed51236
 
dinosourrrrrrrrrrrrrrrrrrrrrr formula .pptx
dinosourrrrrrrrrrrrrrrrrrrrrr formula .pptx
ShohidulIslamSovon
 
Annotaed slides for dynamic programming algorithm
Annotaed slides for dynamic programming algorithm
johnathangamal27
 
Dynamic programming
Dynamic programming
Jay Nagar
 
Presentation (1) (5).pptx in DAA computer
Presentation (1) (5).pptx in DAA computer
MadhurimaKomanduru
 
Presentation (1) (5).pptx in DAA computer
Presentation (1) (5).pptx in DAA computer
MadhurimaKomanduru
 
Introduction to Dynamic Programming, Principle of Optimality
Introduction to Dynamic Programming, Principle of Optimality
Bhavin Darji
 
W8L1 Introduction & Fibonacci Numbers part 1.pptx
W8L1 Introduction & Fibonacci Numbers part 1.pptx
sakibahmed181234
 
Dynamic programming in Design Analysis and Algorithms
Dynamic programming in Design Analysis and Algorithms
NikunjGoyal20
 
Dynamic Programming
Dynamic Programming
paramalways
 
Dynamic Programming.pptx
Dynamic Programming.pptx
MuktarHossain13
 
Introduction to dynamic programming
Introduction to dynamic programming
Amisha Narsingani
 
Dynamic programming class 16
Dynamic programming class 16
Kumar
 
L21_L27_Unit_5_Dynamic_Programming Computer Science
L21_L27_Unit_5_Dynamic_Programming Computer Science
priyanshukumarbt23cs
 
Dynamic programming prasintation eaisy
Dynamic programming prasintation eaisy
ahmed51236
 

Recently uploaded (20)

Chalukyas of Gujrat, Solanki Dynasty NEP.pptx
Chalukyas of Gujrat, Solanki Dynasty NEP.pptx
Dr. Ravi Shankar Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
VCE Literature Section A Exam Response Guide
VCE Literature Section A Exam Response Guide
jpinnuck
 
ENGLISH-5 Q1 Lesson 1.pptx - Story Elements
ENGLISH-5 Q1 Lesson 1.pptx - Story Elements
Mayvel Nadal
 
The Man In The Back – Exceptional Delaware.pdf
The Man In The Back – Exceptional Delaware.pdf
dennisongomezk
 
ECONOMICS, DISASTER MANAGEMENT, ROAD SAFETY - STUDY MATERIAL [10TH]
ECONOMICS, DISASTER MANAGEMENT, ROAD SAFETY - STUDY MATERIAL [10TH]
SHERAZ AHMAD LONE
 
List View Components in Odoo 18 - Odoo Slides
List View Components in Odoo 18 - Odoo Slides
Celine George
 
Code Profiling in Odoo 18 - Odoo 18 Slides
Code Profiling in Odoo 18 - Odoo 18 Slides
Celine George
 
Values Education 10 Quarter 1 Module .pptx
Values Education 10 Quarter 1 Module .pptx
JBPafin
 
INDUCTIVE EFFECT slide for first prof pharamacy students
INDUCTIVE EFFECT slide for first prof pharamacy students
SHABNAM FAIZ
 
How to Customize Quotation Layouts in Odoo 18
How to Customize Quotation Layouts in Odoo 18
Celine George
 
Aprendendo Arquitetura Framework Salesforce - Dia 02
Aprendendo Arquitetura Framework Salesforce - Dia 02
Mauricio Alexandre Silva
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 6-14-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 6-14-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
Pests of Maize: An comprehensive overview.pptx
Pests of Maize: An comprehensive overview.pptx
Arshad Shaikh
 
LDMMIA Shop & Student News Summer Solstice 25
LDMMIA Shop & Student News Summer Solstice 25
LDM & Mia eStudios
 
Filipino 9 Maikling Kwento Ang Ama Panitikang Asiyano
Filipino 9 Maikling Kwento Ang Ama Panitikang Asiyano
sumadsadjelly121997
 
How payment terms are configured in Odoo 18
How payment terms are configured in Odoo 18
Celine George
 
Great Governors' Send-Off Quiz 2025 Prelims IIT KGP
Great Governors' Send-Off Quiz 2025 Prelims IIT KGP
IIT Kharagpur Quiz Club
 
Romanticism in Love and Sacrifice An Analysis of Oscar Wilde’s The Nightingal...
Romanticism in Love and Sacrifice An Analysis of Oscar Wilde’s The Nightingal...
KaryanaTantri21
 
K12 Tableau User Group virtual event June 18, 2025
K12 Tableau User Group virtual event June 18, 2025
dogden2
 
NSUMD_M1 Library Orientation_June 11, 2025.pptx
NSUMD_M1 Library Orientation_June 11, 2025.pptx
Julie Sarpy
 
VCE Literature Section A Exam Response Guide
VCE Literature Section A Exam Response Guide
jpinnuck
 
ENGLISH-5 Q1 Lesson 1.pptx - Story Elements
ENGLISH-5 Q1 Lesson 1.pptx - Story Elements
Mayvel Nadal
 
The Man In The Back – Exceptional Delaware.pdf
The Man In The Back – Exceptional Delaware.pdf
dennisongomezk
 
ECONOMICS, DISASTER MANAGEMENT, ROAD SAFETY - STUDY MATERIAL [10TH]
ECONOMICS, DISASTER MANAGEMENT, ROAD SAFETY - STUDY MATERIAL [10TH]
SHERAZ AHMAD LONE
 
List View Components in Odoo 18 - Odoo Slides
List View Components in Odoo 18 - Odoo Slides
Celine George
 
Code Profiling in Odoo 18 - Odoo 18 Slides
Code Profiling in Odoo 18 - Odoo 18 Slides
Celine George
 
Values Education 10 Quarter 1 Module .pptx
Values Education 10 Quarter 1 Module .pptx
JBPafin
 
INDUCTIVE EFFECT slide for first prof pharamacy students
INDUCTIVE EFFECT slide for first prof pharamacy students
SHABNAM FAIZ
 
How to Customize Quotation Layouts in Odoo 18
How to Customize Quotation Layouts in Odoo 18
Celine George
 
Aprendendo Arquitetura Framework Salesforce - Dia 02
Aprendendo Arquitetura Framework Salesforce - Dia 02
Mauricio Alexandre Silva
 
Pests of Maize: An comprehensive overview.pptx
Pests of Maize: An comprehensive overview.pptx
Arshad Shaikh
 
LDMMIA Shop & Student News Summer Solstice 25
LDMMIA Shop & Student News Summer Solstice 25
LDM & Mia eStudios
 
Filipino 9 Maikling Kwento Ang Ama Panitikang Asiyano
Filipino 9 Maikling Kwento Ang Ama Panitikang Asiyano
sumadsadjelly121997
 
How payment terms are configured in Odoo 18
How payment terms are configured in Odoo 18
Celine George
 
Great Governors' Send-Off Quiz 2025 Prelims IIT KGP
Great Governors' Send-Off Quiz 2025 Prelims IIT KGP
IIT Kharagpur Quiz Club
 
Romanticism in Love and Sacrifice An Analysis of Oscar Wilde’s The Nightingal...
Romanticism in Love and Sacrifice An Analysis of Oscar Wilde’s The Nightingal...
KaryanaTantri21
 
K12 Tableau User Group virtual event June 18, 2025
K12 Tableau User Group virtual event June 18, 2025
dogden2
 
NSUMD_M1 Library Orientation_June 11, 2025.pptx
NSUMD_M1 Library Orientation_June 11, 2025.pptx
Julie Sarpy
 
Ad

Dynamic Programming Algorithm CSI-504.pdf

  • 2. What is Dynamic Programming (DP) Algorithm Dynamic Programming (DP) is a method used in mathematics and computer science to solve complex problems by breaking them down into simpler subproblems. By solving each subproblem only once and storing the results, it avoids redundant computations, leading to more efficient solutions for a wide range of problems.
  • 3. How does DP works • Identify Subproblems: Divide the main problem into smaller, independent subproblems. • Store Solutions: Solve each subproblem and store the solution in a table or array. • Build Up Solutions: Use the stored solutions to build up the solution to the main problem. • Avoid Redundancy: By storing solutions, DP ensures that each subproblem is solved only once, reducing computation time.
  • 4. Example of Dynamic Programming (DP) Example 1: Consider the problem of finding the Fibonacci sequence: Fibonacci sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, … Brute Force Approach: To find the nth Fibonacci number using a brute force approach, you would simply add the (n-1)th and (n-2)th Fibonacci numbers. This would work, but it would be inefficient for large values of n, as it would require calculating all the previous Fibonacci numbers.
  • 5. F(0) = 0 F(1) = 1 F(n) = F(n-1) + F(n-2)
  • 6. Fibonacci Series using Dynamic Programming Subproblems: F(0), F(1), F(2), F(3), … Store Solutions: Create a table to store the values of F(n) as they are calculated. Build Up Solutions: For F(n), look up F(n-1) and F(n-2) in the table and add them. Avoid Redundancy: The table ensures that each subproblem (e.g., F(2)) is solved only once. By using DP, we can efficiently calculate the Fibonacci sequence without having to recompute subproblems.
  • 7. Approaches of Dynamic Programming (DP) Dynamic programming can be achieved using two approaches: 01. Top-Down Approach 02. Bottom-Down Approach
  • 8. Top-Down Approach In the top-down approach, also known as memoization, we start with the final solution and recursively break it down into smaller subproblems. To avoid redundant calculations, we store the results of solved subproblems in a memoization table. Let’s breakdown Top down approach: • Starts with the final solution and recursively breaks it down into smaller subproblems. • Stores the solutions to subproblems in a table to avoid redundant calculations. • Suitable when the number of subproblems is large and many of them are reused.
  • 9. Bottom-Down Approach In the bottom-up approach, also known as tabulation, we start with the smallest subproblems and gradually build up to the final solution. We store the results of solved subproblems in a table to avoid redundant calculations. Let’s breakdown Bottom-up approach: • Starts with the smallest subproblems and gradually builds up to the final solution. • Fills a table with solutions to subproblems in a bottom-up manner. • Suitable when the number of subproblems is small and the optimal solution can be directly computed from the solutions to smaller subproblems.
  • 10. Applications: Dynamic programming has a wide range of applications, including: • Optimization: Knapsack problem, shortest path problem, maximum subarray problem • Computer Science: Longest common subsequence, edit distance, string matching • Operations Research: Inventory management, scheduling, resource allocation