SlideShare a Scribd company logo
Dynamic
Programming
Contents
Introduction
Elements of
Dynamic Programming
Bibliography &
References
Introduction
*picture taken from https://www.engadget.com/2019/03/22/mit-ai-automated-neural-network-design/ on April, 2019
Dynamic Programming, like the divide – and – conquer method, solves
problems by combining the solutions to subsproblems.
Partitioning the problems into smaller part ( can be called as
subproblems ) solving them recursively then combining the solution to
solve the original Problems.
This method is usually applied for solving optimization problems.
Definition
Characterize the structure of an Optimal Solution.
Recursively define the value of an Optimal Solution.
Compute the value of an Optimal Solution, typically in a bottom-up
fashion.
Construct an optimal solution from computed information.
Sequence of Four Steps
Elements of
Dynamic Programming
*picture taken from http://www.consorzioc2t.it/attivita-scientifica/centro-ricerca-ict/ on April, 2019
Problems that having Optimal Substructure Property, if it is Optimum
Solution from that problems can be structured using Optimal Structure
from that sub-problems.
Optimal Substructure
Says that a stick that have length of n, divided into smaller part and have
variety of price depending on the length. Like below :
Optimal Substructure
Determine the Maximum revenue that can be reach from selling all parts of the
stick!
.
Lets pretend that value of n is 4 so, the probability of the revenue that can be
get is :
Optimal Substructure
4 Parts with length of 1. Revenue = 1 x 4 = 4
2 Parts with length of 1 and 1 Part with length of 2. Revenue = 2 x 1 + 5 = 7.
1 Part with length of 1 and 1 Part with length of 3. Revenue = 1 x 1 + 1 x 8 = 9.
2 Parts with length of 2. Revenue = 2 x 5 = 10.
1 Part with length of 4. Revenue = 1 x 9 = 9.
If Recursive subproblem is revisited multiple times, it can be optimized
by remembering the solution of that subproblem.
Overlapping Subproblems
Overlapping Subproblems
F[5]
F[3]F[4]
F[3] F[2]
F[2] F[1] F[0]
F[1] F[0]
F[2] F[1]
F[1] F[0]
Fibonacci Sequence
Runs like a normal recursion problem.
But checks a lookup table before
computing its solutions.
Saves its solution on the lookup table
after its computation.
Only has a solution to a problem that it
has faced.
Overlapping Subproblems
Memoization ( Top – Down )
Method
Runs the problem from the bottom of the
recursion.
Checks the lookup table before creating a
solution.
Save every solution along the way to the
lookup table.
Has every solution below the specified
subproblem.
Tabulation ( Bottom – Up )
Method
Use the table s[ i, j ] saves a significant amount of work when reconstructing an optimal solution
for matrix-chain multiplication.
Suppose that we did not maintain the s[ i, j ] table, having filled in only the table m[ i, j ]
containing optimal subproblem costs. It would take θ ( j – i ) = ω ( 1 ) time to reconstruct.
By storing in s[ i, j ] the index of the matrix at which we split the product Ai, Ai+1, …..Aj , we
can reconstruct each choice in O ( 1 ) time.
Reconstructing an optimal solution
oized version of RECURSIVE-MATRIX-CHAIN with top-down method.
A memoized recursive algorithm maintains an entry in a table for the solution to each
subproblem. Each table entry initially contains a special value to indicate that the entry has yet
to be filled in. When the subproblem is first encountered as the recursive algorithm unfolds, its
solution is computed and then stored in the table.
Memoization
Memoized version of RECURSIVE-
MATRIX-CHAIN with top-down method.
Like the bottom-up dynamic-programming algorithm MATRIX-CHAIN-ORDER, the procedure
MEMOIZED-MATRIX-CHAIN runs in O(n3)time. Line 5 of MEMOIZED-MATRIX-CHAIN
executes θ (n2) times.
In general practice, if all subproblems must be solved at least once, a bottom-up dynamic-
programming algorithm usually outperforms the corresponding top-down memoized algorithm
by a constant factor, because the bottom-up algorithm has no overhead for recursion and less
overhead for maintaining the table.
Memoization
Bibliography and
References
*picture taken from http://fortune.com/2015/09/24/ebook-sales/ on April, 2019
Thomas H. Cormen, “Introduction to Algorithms”, 3rd
Edition, MIT Press, 2009. ( Page 359 – 360, 378 – 390 )
"Overlapping Subproblems Property in Dynamic Programming
DP-1 GeeksforGeeks", GeeksforGeeks, 2019. [Online].
Available: https://www.geeksforgeeks.org/overlapping
subproblems-property-in-dynamic-programming-dp-1/
[Accessed: 29- Apr- 2019]
[1]
[2]

More Related Content

What's hot (20)

PPTX
dynamic programming complete by Mumtaz Ali (03154103173)
Mumtaz Ali
 
PPTX
Algorithmic research
Merlin Florrence
 
PPTX
Dynamic programming
Yıldırım Tam
 
PDF
DP
Subba Oota
 
PPT
Algorithm Design Presentation
Kawsar Ahmed
 
PPTX
Dynamic programming prasintation eaisy
ahmed51236
 
PPTX
Our presentation on algorithm design
Nahid Hasan
 
PPT
Dynamic programming in Algorithm Analysis
Rajendran
 
PPTX
Dynamic Programming
contact2kazi
 
PPT
Matlab 4
ak2011031
 
PDF
Dynamic programming
Jay Nagar
 
PPT
Algorithm Design
MD.ASHIQUZZAMAN KHONDAKER
 
PPTX
Linear Programming
Rashid Ansari
 
PPTX
DS ppt
kirupasuchi1996
 
PPTX
Linear Programming Problem
A. Dally Maria Evangeline
 
PPTX
Solving linear programming model by simplex method
Roshan Kumar Patel
 
PPT
dynamic programming Rod cutting class
giridaroori
 
PPT
Lecture 8 dynamic programming
Oye Tu
 
PDF
Dynamic programming
Amit Kumar Rathi
 
PDF
linear programming
DagnaygebawGoshme
 
dynamic programming complete by Mumtaz Ali (03154103173)
Mumtaz Ali
 
Algorithmic research
Merlin Florrence
 
Dynamic programming
Yıldırım Tam
 
Algorithm Design Presentation
Kawsar Ahmed
 
Dynamic programming prasintation eaisy
ahmed51236
 
Our presentation on algorithm design
Nahid Hasan
 
Dynamic programming in Algorithm Analysis
Rajendran
 
Dynamic Programming
contact2kazi
 
Matlab 4
ak2011031
 
Dynamic programming
Jay Nagar
 
Algorithm Design
MD.ASHIQUZZAMAN KHONDAKER
 
Linear Programming
Rashid Ansari
 
Linear Programming Problem
A. Dally Maria Evangeline
 
Solving linear programming model by simplex method
Roshan Kumar Patel
 
dynamic programming Rod cutting class
giridaroori
 
Lecture 8 dynamic programming
Oye Tu
 
Dynamic programming
Amit Kumar Rathi
 
linear programming
DagnaygebawGoshme
 

Similar to Algorithm_Dynamic Programming (20)

PPTX
ADA Unit 2.pptx
AmanKumar879992
 
PDF
L21_L27_Unit_5_Dynamic_Programming Computer Science
priyanshukumarbt23cs
 
PPTX
Dynamic programming in Design Analysis and Algorithms
NikunjGoyal20
 
PPT
Lecture11
Nv Thejaswini
 
PPTX
dinosourrrrrrrrrrrrrrrrrrrrrr formula .pptx
ShohidulIslamSovon
 
PPTX
Module 2ppt.pptx divid and conquer method
JyoReddy9
 
PPTX
Annotaed slides for dynamic programming algorithm
johnathangamal27
 
PPTX
Dynamic Programming Intro in Algorithm Design
AhsanRazaKolachi
 
PPTX
Elements of Dynamic Programming
Vishwajeet Shabadi
 
PPT
5.3 dynamic programming 03
Krish_ver2
 
PPTX
Dynamic programmng2
debolina13
 
PPTX
Dynamic Programming - Part 1
Amrinder Arora
 
PPT
Chapter 16
ashish bansal
 
PPTX
Dynamic programming - fundamentals review
ElifTech
 
PPTX
DYNAMIC_________________________PROGRAMMING.pptx
nazmusshakib335
 
PDF
Daa chapter 3
B.Kirron Reddi
 
PPTX
unit-4-dynamic programming
hodcsencet
 
PPTX
Chapter 5.pptx
Tekle12
 
PPTX
Dynamic Programing.pptx good for understanding
HUSNAINAHMAD39
 
PPT
dynamic-programming unit 3 power point presentation
Shrinivasa6
 
ADA Unit 2.pptx
AmanKumar879992
 
L21_L27_Unit_5_Dynamic_Programming Computer Science
priyanshukumarbt23cs
 
Dynamic programming in Design Analysis and Algorithms
NikunjGoyal20
 
Lecture11
Nv Thejaswini
 
dinosourrrrrrrrrrrrrrrrrrrrrr formula .pptx
ShohidulIslamSovon
 
Module 2ppt.pptx divid and conquer method
JyoReddy9
 
Annotaed slides for dynamic programming algorithm
johnathangamal27
 
Dynamic Programming Intro in Algorithm Design
AhsanRazaKolachi
 
Elements of Dynamic Programming
Vishwajeet Shabadi
 
5.3 dynamic programming 03
Krish_ver2
 
Dynamic programmng2
debolina13
 
Dynamic Programming - Part 1
Amrinder Arora
 
Chapter 16
ashish bansal
 
Dynamic programming - fundamentals review
ElifTech
 
DYNAMIC_________________________PROGRAMMING.pptx
nazmusshakib335
 
Daa chapter 3
B.Kirron Reddi
 
unit-4-dynamic programming
hodcsencet
 
Chapter 5.pptx
Tekle12
 
Dynamic Programing.pptx good for understanding
HUSNAINAHMAD39
 
dynamic-programming unit 3 power point presentation
Shrinivasa6
 
Ad

Recently uploaded (20)

PDF
5 Things to Consider When Deploying AI in Your Enterprise
Safe Software
 
PDF
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Saikat Basu
 
PDF
Hyderabad MuleSoft In-Person Meetup (June 21, 2025) Slides
Ravi Tamada
 
PDF
My Journey from CAD to BIM: A True Underdog Story
Safe Software
 
PDF
Redefining Work in the Age of AI - What to expect? How to prepare? Why it mat...
Malinda Kapuruge
 
PDF
Hello I'm "AI" Your New _________________
Dr. Tathagat Varma
 
PDF
Optimizing the trajectory of a wheel loader working in short loading cycles
Reno Filla
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
Dev Dives: Accelerating agentic automation with Autopilot for Everyone
UiPathCommunity
 
PDF
99 Bottles of Trust on the Wall — Operational Principles for Trust in Cyber C...
treyka
 
PDF
Darley - FIRST Copenhagen Lightning Talk (2025-06-26) Epochalypse 2038 - Time...
treyka
 
PDF
The Future of Product Management in AI ERA.pdf
Alyona Owens
 
PDF
Why aren't you using FME Flow's CPU Time?
Safe Software
 
PDF
ArcGIS Utility Network Migration - The Hunter Water Story
Safe Software
 
PPTX
Enabling the Digital Artisan – keynote at ICOCI 2025
Alan Dix
 
PDF
Bridging CAD, IBM TRIRIGA & GIS with FME: The Portland Public Schools Case
Safe Software
 
PPTX
Smarter Governance with AI: What Every Board Needs to Know
OnBoard
 
PDF
Enhancing Environmental Monitoring with Real-Time Data Integration: Leveragin...
Safe Software
 
PDF
GDG Cloud Southlake #44: Eyal Bukchin: Tightening the Kubernetes Feedback Loo...
James Anderson
 
PDF
Proactive Server and System Monitoring with FME: Using HTTP and System Caller...
Safe Software
 
5 Things to Consider When Deploying AI in Your Enterprise
Safe Software
 
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Saikat Basu
 
Hyderabad MuleSoft In-Person Meetup (June 21, 2025) Slides
Ravi Tamada
 
My Journey from CAD to BIM: A True Underdog Story
Safe Software
 
Redefining Work in the Age of AI - What to expect? How to prepare? Why it mat...
Malinda Kapuruge
 
Hello I'm "AI" Your New _________________
Dr. Tathagat Varma
 
Optimizing the trajectory of a wheel loader working in short loading cycles
Reno Filla
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Dev Dives: Accelerating agentic automation with Autopilot for Everyone
UiPathCommunity
 
99 Bottles of Trust on the Wall — Operational Principles for Trust in Cyber C...
treyka
 
Darley - FIRST Copenhagen Lightning Talk (2025-06-26) Epochalypse 2038 - Time...
treyka
 
The Future of Product Management in AI ERA.pdf
Alyona Owens
 
Why aren't you using FME Flow's CPU Time?
Safe Software
 
ArcGIS Utility Network Migration - The Hunter Water Story
Safe Software
 
Enabling the Digital Artisan – keynote at ICOCI 2025
Alan Dix
 
Bridging CAD, IBM TRIRIGA & GIS with FME: The Portland Public Schools Case
Safe Software
 
Smarter Governance with AI: What Every Board Needs to Know
OnBoard
 
Enhancing Environmental Monitoring with Real-Time Data Integration: Leveragin...
Safe Software
 
GDG Cloud Southlake #44: Eyal Bukchin: Tightening the Kubernetes Feedback Loo...
James Anderson
 
Proactive Server and System Monitoring with FME: Using HTTP and System Caller...
Safe Software
 
Ad

Algorithm_Dynamic Programming

  • 3. Introduction *picture taken from https://www.engadget.com/2019/03/22/mit-ai-automated-neural-network-design/ on April, 2019
  • 4. Dynamic Programming, like the divide – and – conquer method, solves problems by combining the solutions to subsproblems. Partitioning the problems into smaller part ( can be called as subproblems ) solving them recursively then combining the solution to solve the original Problems. This method is usually applied for solving optimization problems. Definition
  • 5. Characterize the structure of an Optimal Solution. Recursively define the value of an Optimal Solution. Compute the value of an Optimal Solution, typically in a bottom-up fashion. Construct an optimal solution from computed information. Sequence of Four Steps
  • 6. Elements of Dynamic Programming *picture taken from http://www.consorzioc2t.it/attivita-scientifica/centro-ricerca-ict/ on April, 2019
  • 7. Problems that having Optimal Substructure Property, if it is Optimum Solution from that problems can be structured using Optimal Structure from that sub-problems. Optimal Substructure
  • 8. Says that a stick that have length of n, divided into smaller part and have variety of price depending on the length. Like below : Optimal Substructure Determine the Maximum revenue that can be reach from selling all parts of the stick!
  • 9. . Lets pretend that value of n is 4 so, the probability of the revenue that can be get is : Optimal Substructure 4 Parts with length of 1. Revenue = 1 x 4 = 4 2 Parts with length of 1 and 1 Part with length of 2. Revenue = 2 x 1 + 5 = 7. 1 Part with length of 1 and 1 Part with length of 3. Revenue = 1 x 1 + 1 x 8 = 9. 2 Parts with length of 2. Revenue = 2 x 5 = 10. 1 Part with length of 4. Revenue = 1 x 9 = 9.
  • 10. If Recursive subproblem is revisited multiple times, it can be optimized by remembering the solution of that subproblem. Overlapping Subproblems
  • 11. Overlapping Subproblems F[5] F[3]F[4] F[3] F[2] F[2] F[1] F[0] F[1] F[0] F[2] F[1] F[1] F[0] Fibonacci Sequence
  • 12. Runs like a normal recursion problem. But checks a lookup table before computing its solutions. Saves its solution on the lookup table after its computation. Only has a solution to a problem that it has faced. Overlapping Subproblems Memoization ( Top – Down ) Method Runs the problem from the bottom of the recursion. Checks the lookup table before creating a solution. Save every solution along the way to the lookup table. Has every solution below the specified subproblem. Tabulation ( Bottom – Up ) Method
  • 13. Use the table s[ i, j ] saves a significant amount of work when reconstructing an optimal solution for matrix-chain multiplication. Suppose that we did not maintain the s[ i, j ] table, having filled in only the table m[ i, j ] containing optimal subproblem costs. It would take θ ( j – i ) = ω ( 1 ) time to reconstruct. By storing in s[ i, j ] the index of the matrix at which we split the product Ai, Ai+1, …..Aj , we can reconstruct each choice in O ( 1 ) time. Reconstructing an optimal solution
  • 14. oized version of RECURSIVE-MATRIX-CHAIN with top-down method. A memoized recursive algorithm maintains an entry in a table for the solution to each subproblem. Each table entry initially contains a special value to indicate that the entry has yet to be filled in. When the subproblem is first encountered as the recursive algorithm unfolds, its solution is computed and then stored in the table. Memoization Memoized version of RECURSIVE- MATRIX-CHAIN with top-down method.
  • 15. Like the bottom-up dynamic-programming algorithm MATRIX-CHAIN-ORDER, the procedure MEMOIZED-MATRIX-CHAIN runs in O(n3)time. Line 5 of MEMOIZED-MATRIX-CHAIN executes θ (n2) times. In general practice, if all subproblems must be solved at least once, a bottom-up dynamic- programming algorithm usually outperforms the corresponding top-down memoized algorithm by a constant factor, because the bottom-up algorithm has no overhead for recursion and less overhead for maintaining the table. Memoization
  • 16. Bibliography and References *picture taken from http://fortune.com/2015/09/24/ebook-sales/ on April, 2019
  • 17. Thomas H. Cormen, “Introduction to Algorithms”, 3rd Edition, MIT Press, 2009. ( Page 359 – 360, 378 – 390 ) "Overlapping Subproblems Property in Dynamic Programming DP-1 GeeksforGeeks", GeeksforGeeks, 2019. [Online]. Available: https://www.geeksforgeeks.org/overlapping subproblems-property-in-dynamic-programming-dp-1/ [Accessed: 29- Apr- 2019] [1] [2]