SlideShare a Scribd company logo
1 of 12
Dynamic Programming
Shashikant V. Athawale
Assistant Professor ,Computer Engineering Department
AISSMS College of Engineering,
Kennedy Road, Pune , MS, India - 411001
1.Optimal Binary Search Tree(OBST)
2.0/1 Knapsack
3.Matrix Chain Multiplication
•Dynamic Programming is an algorithm design
method that can be used when the solution to a
problem may be viewed as the result of a sequence
of decisions.
•Dynamic programming (usually referred to as DP
) is a very powerful technique to solve a particular
class of problems. It demands very elegant
formulation of the approach and simple thinking and
the coding part is very easy.
 Example binary search trees 3,7,9,12
3
7
12
9
(a) (b)
9
3
7
12
12
3
7
9
(c)
12
3
7
9
(d)
7 -5
 n identifiers : a1
<a2
<a3
<…< an
Pi
, 1≤i≤n : the probability that ai
is searched.
Qi
, 0≤i≤n : the probability that x is searched
where ai
< x < ai+1
(a0
=-∞, an+1
=∞).
1
01
=+ ∑∑ ==
n
i
i
n
i
i QP
7 -6
 Let C(i, j) denote the cost of an optimal binary
search tree containing ai
,…,aj
.
 The cost of the optimal binary search tree with ak
as
its root :
ak
a1 ...a k-1 ak+1 ...a n
P 1 ...P k-1
Q 0
...Q k-1
P k+1 ...P n
Q k
...Q n
C(1,k-1) C(k+1,n)
( ) ( ) ( ) ( )












+++++





−++++= ∑∑ +=
−
=
≤≤
n1,kCQPQ1k1,CQPQPminn)C(1,
n
1km
mmk
1k
1m
mm0k
nk1
7 -7
( ) ( )
( ) ( )
( ) ( ) ( )






+++++−=









+++++









−++++=
∑
∑
∑
=
≤≤
+=
−
=
≤≤
j
im
mm1-i
jki
j
1km
mmk
1k
im
mm1-ik
jki
QPQj1,kC1ki,Cmin
j1,kCQPQ
1ki,CQPQPminj)C(i,
ak
ai
...ak-1
ak+1
...aj
Pi...Pk-1
Qi-1...Qk-1
Pk+1...Pj
Qk
...Qj
C(i,k-1) C(k+1,j)
8
 Given: A set S of n items, with each item i having
 wi - a positive weight
 bi - a positive benefit
 Goal: Choose items with maximum total benefit but with
weight at most W.
 If we are not allowed to take fractional amounts, then this
is the 0/1 knapsack problem.
 In this case, we let Tdenote the set of items we take
 Objective: maximize
 Constraint:
∑∈Ti
ib
∑∈
≤
Ti
i Ww
9
 Recall the definition of B[k,w]
 Since B[k,w] is defined in
terms of B[k−1,*], we can
use two arrays of instead of a
matrix
 Running time: O(nW).
 Not a polynomial-time
algorithm since W may be
large
 This is a pseudo-polynomial
time algorithm
Algorithm 01Knapsack(S, W):
Input: set S of n items with benefit bi
and weight wi; maximum weight W
Output: benefit of best subset of S with
weight at most W
let A and B be arrays of length W + 1
for w ← 0 to W do
B[w] ← 0
for k ← 1 to n do
copy array B into array A
for w ← wk to W do
if A[w−wk] + bk > A[w] then
B[w] ← A[w−wk] + bk
return B[W]



+−−−
>−
=
else}],1[],,1[max{
if],1[
],[
kk
k
bwwkBwkB
wwwkB
wkB
7 -10
 n matrices A1, A2, …, An with size
p0× p1, p1× p2, p2× p3, …, pn-1× pn
To determine the multiplication order such that # of
scalar multiplications is minimized.
 To compute Ai× Ai+1, we need pi-1pipi+1 scalar
multiplications.
e.g. n=4, A1: 3 × 5, A2: 5 × 4, A3: 4 × 2, A4: 2 × 5
((A1 × A2) × A3) × A4, # of scalar multiplications:
3 * 5 * 4 + 3 * 4 * 2 + 3 * 2 * 5 = 114
(A1 × (A2 × A3)) × A4, # of scalar multiplications:
3 * 5 * 2 + 5 * 4 * 2 + 3 * 2 * 5 = 100
(A1 × A2) × (A3 × A4), # of scalar multiplications:
3 * 5 * 4 + 3 * 4 * 5 + 4 * 2 * 5 = 160
7 -11
 Let m(i, j) denote the minimum cost for computing
Ai× Ai+1× … × Aj
 Computation sequence :
 Time complexity : O(n3
)
{ } jiif
jiif
pppj)1,m(kk)m(i,min
0
j)m(i,
jk1i
1-jki
<
=




+++
=
−
≤≤
THANK YOU

More Related Content

What's hot

Longest Common Subsequence & Matrix Chain Multiplication
Longest Common Subsequence & Matrix Chain MultiplicationLongest Common Subsequence & Matrix Chain Multiplication
Longest Common Subsequence & Matrix Chain MultiplicationJaneAlamAdnan
 
5.3 dynamic programming 03
5.3 dynamic programming 035.3 dynamic programming 03
5.3 dynamic programming 03Krish_ver2
 
Dynamic programming1
Dynamic programming1Dynamic programming1
Dynamic programming1debolina13
 
Matrix mult class-17
Matrix mult class-17Matrix mult class-17
Matrix mult class-17Kumar
 
Operation research bba15
Operation research bba15Operation research bba15
Operation research bba15sonal CHAUHAN
 
Ms nikita greedy agorithm
Ms nikita greedy agorithmMs nikita greedy agorithm
Ms nikita greedy agorithmNikitagupta123
 
Matrix chain multiplication by MHM
Matrix chain multiplication by MHMMatrix chain multiplication by MHM
Matrix chain multiplication by MHMMd Mosharof Hosen
 
dynamic programming Rod cutting class
dynamic programming Rod cutting classdynamic programming Rod cutting class
dynamic programming Rod cutting classgiridaroori
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programmingGopi Saiteja
 
Polynomials and Curve Fitting in MATLAB
Polynomials and Curve Fitting in MATLABPolynomials and Curve Fitting in MATLAB
Polynomials and Curve Fitting in MATLABShameer Ahmed Koya
 
Dynamic Programming
Dynamic ProgrammingDynamic Programming
Dynamic ProgrammingSahil Kumar
 
Approximation algorithms
Approximation algorithmsApproximation algorithms
Approximation algorithmsGanesh Solanke
 
test pre
test pretest pre
test prefarazch
 

What's hot (20)

Longest Common Subsequence & Matrix Chain Multiplication
Longest Common Subsequence & Matrix Chain MultiplicationLongest Common Subsequence & Matrix Chain Multiplication
Longest Common Subsequence & Matrix Chain Multiplication
 
5.3 dynamic programming 03
5.3 dynamic programming 035.3 dynamic programming 03
5.3 dynamic programming 03
 
Dynamic programming1
Dynamic programming1Dynamic programming1
Dynamic programming1
 
Matrix mult class-17
Matrix mult class-17Matrix mult class-17
Matrix mult class-17
 
Operation research bba15
Operation research bba15Operation research bba15
Operation research bba15
 
Ms nikita greedy agorithm
Ms nikita greedy agorithmMs nikita greedy agorithm
Ms nikita greedy agorithm
 
Matrix chain multiplication by MHM
Matrix chain multiplication by MHMMatrix chain multiplication by MHM
Matrix chain multiplication by MHM
 
dynamic programming Rod cutting class
dynamic programming Rod cutting classdynamic programming Rod cutting class
dynamic programming Rod cutting class
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
 
Unit 3 daa
Unit 3 daaUnit 3 daa
Unit 3 daa
 
Lab no.08
Lab no.08Lab no.08
Lab no.08
 
DP
DPDP
DP
 
Backtraking pic&amp;def
Backtraking pic&amp;defBacktraking pic&amp;def
Backtraking pic&amp;def
 
Greedy method by Dr. B. J. Mohite
Greedy method by Dr. B. J. MohiteGreedy method by Dr. B. J. Mohite
Greedy method by Dr. B. J. Mohite
 
Polynomials and Curve Fitting in MATLAB
Polynomials and Curve Fitting in MATLABPolynomials and Curve Fitting in MATLAB
Polynomials and Curve Fitting in MATLAB
 
Dynamic Programming
Dynamic ProgrammingDynamic Programming
Dynamic Programming
 
Greedy
GreedyGreedy
Greedy
 
Knapsack problem using fixed tuple
Knapsack problem using fixed tupleKnapsack problem using fixed tuple
Knapsack problem using fixed tuple
 
Approximation algorithms
Approximation algorithmsApproximation algorithms
Approximation algorithms
 
test pre
test pretest pre
test pre
 

Similar to Dynamic Programming Techniques for Optimization Problems

Support Vector Machines Simply
Support Vector Machines SimplySupport Vector Machines Simply
Support Vector Machines SimplyEmad Nabil
 
Processing Reachability Queries with Realistic Constraints on Massive Network...
Processing Reachability Queries with Realistic Constraints on Massive Network...Processing Reachability Queries with Realistic Constraints on Massive Network...
Processing Reachability Queries with Realistic Constraints on Massive Network...BigMine
 
More on randomization semi-definite programming and derandomization
More on randomization semi-definite programming and derandomizationMore on randomization semi-definite programming and derandomization
More on randomization semi-definite programming and derandomizationAbner Chih Yi Huang
 
Dynamic1
Dynamic1Dynamic1
Dynamic1MyAlome
 
Neural Networks: Principal Component Analysis (PCA)
Neural Networks: Principal Component Analysis (PCA)Neural Networks: Principal Component Analysis (PCA)
Neural Networks: Principal Component Analysis (PCA)Mostafa G. M. Mostafa
 
Mid semexam | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Mid semexam | Theory of Computation | Akash Anand | MTH 401A | IIT KanpurMid semexam | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Mid semexam | Theory of Computation | Akash Anand | MTH 401A | IIT KanpurVivekananda Samiti
 
linear SVM.ppt
linear SVM.pptlinear SVM.ppt
linear SVM.pptMahimMajee
 
Matlab polynimials and curve fitting
Matlab polynimials and curve fittingMatlab polynimials and curve fitting
Matlab polynimials and curve fittingAmeen San
 
machine learning.pptx
machine learning.pptxmachine learning.pptx
machine learning.pptxAbdusSadik
 
Methods of Manifold Learning for Dimension Reduction of Large Data Sets
Methods of Manifold Learning for Dimension Reduction of Large Data SetsMethods of Manifold Learning for Dimension Reduction of Large Data Sets
Methods of Manifold Learning for Dimension Reduction of Large Data SetsRyan B Harvey, CSDP, CSM
 
Low-rank matrix approximations in Python by Christian Thurau PyData 2014
Low-rank matrix approximations in Python by Christian Thurau PyData 2014Low-rank matrix approximations in Python by Christian Thurau PyData 2014
Low-rank matrix approximations in Python by Christian Thurau PyData 2014PyData
 
DimensionalityReduction.pptx
DimensionalityReduction.pptxDimensionalityReduction.pptx
DimensionalityReduction.pptx36rajneekant
 
lecture14-SVMs (1).ppt
lecture14-SVMs (1).pptlecture14-SVMs (1).ppt
lecture14-SVMs (1).pptmuqadsatareen
 
Real World Haskell: Lecture 5
Real World Haskell: Lecture 5Real World Haskell: Lecture 5
Real World Haskell: Lecture 5Bryan O'Sullivan
 
Design and Implementation of Parallel and Randomized Approximation Algorithms
Design and Implementation of Parallel and Randomized Approximation AlgorithmsDesign and Implementation of Parallel and Randomized Approximation Algorithms
Design and Implementation of Parallel and Randomized Approximation AlgorithmsAjay Bidyarthy
 
Advanced matlab codigos matematicos
Advanced matlab codigos matematicosAdvanced matlab codigos matematicos
Advanced matlab codigos matematicosKmilo Bolaños
 
Constrained Support Vector Quantile Regression for Conditional Quantile Estim...
Constrained Support Vector Quantile Regression for Conditional Quantile Estim...Constrained Support Vector Quantile Regression for Conditional Quantile Estim...
Constrained Support Vector Quantile Regression for Conditional Quantile Estim...Kostas Hatalis, PhD
 
An Efficient Convex Hull Algorithm for a Planer Set of Points
An Efficient Convex Hull Algorithm for a Planer Set of PointsAn Efficient Convex Hull Algorithm for a Planer Set of Points
An Efficient Convex Hull Algorithm for a Planer Set of PointsKasun Ranga Wijeweera
 

Similar to Dynamic Programming Techniques for Optimization Problems (20)

Support Vector Machines Simply
Support Vector Machines SimplySupport Vector Machines Simply
Support Vector Machines Simply
 
Processing Reachability Queries with Realistic Constraints on Massive Network...
Processing Reachability Queries with Realistic Constraints on Massive Network...Processing Reachability Queries with Realistic Constraints on Massive Network...
Processing Reachability Queries with Realistic Constraints on Massive Network...
 
More on randomization semi-definite programming and derandomization
More on randomization semi-definite programming and derandomizationMore on randomization semi-definite programming and derandomization
More on randomization semi-definite programming and derandomization
 
Dynamic1
Dynamic1Dynamic1
Dynamic1
 
Neural Networks: Principal Component Analysis (PCA)
Neural Networks: Principal Component Analysis (PCA)Neural Networks: Principal Component Analysis (PCA)
Neural Networks: Principal Component Analysis (PCA)
 
Svm vs ls svm
Svm vs ls svmSvm vs ls svm
Svm vs ls svm
 
cdrw
cdrwcdrw
cdrw
 
Mid semexam | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Mid semexam | Theory of Computation | Akash Anand | MTH 401A | IIT KanpurMid semexam | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Mid semexam | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
 
linear SVM.ppt
linear SVM.pptlinear SVM.ppt
linear SVM.ppt
 
Matlab polynimials and curve fitting
Matlab polynimials and curve fittingMatlab polynimials and curve fitting
Matlab polynimials and curve fitting
 
machine learning.pptx
machine learning.pptxmachine learning.pptx
machine learning.pptx
 
Methods of Manifold Learning for Dimension Reduction of Large Data Sets
Methods of Manifold Learning for Dimension Reduction of Large Data SetsMethods of Manifold Learning for Dimension Reduction of Large Data Sets
Methods of Manifold Learning for Dimension Reduction of Large Data Sets
 
Low-rank matrix approximations in Python by Christian Thurau PyData 2014
Low-rank matrix approximations in Python by Christian Thurau PyData 2014Low-rank matrix approximations in Python by Christian Thurau PyData 2014
Low-rank matrix approximations in Python by Christian Thurau PyData 2014
 
DimensionalityReduction.pptx
DimensionalityReduction.pptxDimensionalityReduction.pptx
DimensionalityReduction.pptx
 
lecture14-SVMs (1).ppt
lecture14-SVMs (1).pptlecture14-SVMs (1).ppt
lecture14-SVMs (1).ppt
 
Real World Haskell: Lecture 5
Real World Haskell: Lecture 5Real World Haskell: Lecture 5
Real World Haskell: Lecture 5
 
Design and Implementation of Parallel and Randomized Approximation Algorithms
Design and Implementation of Parallel and Randomized Approximation AlgorithmsDesign and Implementation of Parallel and Randomized Approximation Algorithms
Design and Implementation of Parallel and Randomized Approximation Algorithms
 
Advanced matlab codigos matematicos
Advanced matlab codigos matematicosAdvanced matlab codigos matematicos
Advanced matlab codigos matematicos
 
Constrained Support Vector Quantile Regression for Conditional Quantile Estim...
Constrained Support Vector Quantile Regression for Conditional Quantile Estim...Constrained Support Vector Quantile Regression for Conditional Quantile Estim...
Constrained Support Vector Quantile Regression for Conditional Quantile Estim...
 
An Efficient Convex Hull Algorithm for a Planer Set of Points
An Efficient Convex Hull Algorithm for a Planer Set of PointsAn Efficient Convex Hull Algorithm for a Planer Set of Points
An Efficient Convex Hull Algorithm for a Planer Set of Points
 

More from Dr Shashikant Athawale (20)

multi threaded and distributed algorithms
multi threaded and distributed algorithms multi threaded and distributed algorithms
multi threaded and distributed algorithms
 
Amortized analysis
Amortized analysisAmortized analysis
Amortized analysis
 
Complexity theory
Complexity theory Complexity theory
Complexity theory
 
Divide and Conquer
Divide and ConquerDivide and Conquer
Divide and Conquer
 
Model and Design
Model and Design Model and Design
Model and Design
 
Fundamental of Algorithms
Fundamental of Algorithms Fundamental of Algorithms
Fundamental of Algorithms
 
CUDA Architecture
CUDA ArchitectureCUDA Architecture
CUDA Architecture
 
Parallel Algorithms- Sorting and Graph
Parallel Algorithms- Sorting and GraphParallel Algorithms- Sorting and Graph
Parallel Algorithms- Sorting and Graph
 
Analytical Models of Parallel Programs
Analytical Models of Parallel ProgramsAnalytical Models of Parallel Programs
Analytical Models of Parallel Programs
 
Basic Communication
Basic CommunicationBasic Communication
Basic Communication
 
Parallel Processing Concepts
Parallel Processing Concepts Parallel Processing Concepts
Parallel Processing Concepts
 
Parallel Processing Concepts
Parallel Processing Concepts Parallel Processing Concepts
Parallel Processing Concepts
 
Parallel algorithms
Parallel algorithms Parallel algorithms
Parallel algorithms
 
Divide and conquer
Divide and conquerDivide and conquer
Divide and conquer
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
 
String matching algorithms
String matching algorithmsString matching algorithms
String matching algorithms
 
Advanced Wireless Technologies
Advanced Wireless TechnologiesAdvanced Wireless Technologies
Advanced Wireless Technologies
 
Vo ip
Vo ipVo ip
Vo ip
 
Vehicular network
Vehicular networkVehicular network
Vehicular network
 
Delay telerant network
Delay telerant networkDelay telerant network
Delay telerant network
 

Recently uploaded

the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxhumanexperienceaaa
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 

Recently uploaded (20)

the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 

Dynamic Programming Techniques for Optimization Problems

  • 1. Dynamic Programming Shashikant V. Athawale Assistant Professor ,Computer Engineering Department AISSMS College of Engineering, Kennedy Road, Pune , MS, India - 411001
  • 2. 1.Optimal Binary Search Tree(OBST) 2.0/1 Knapsack 3.Matrix Chain Multiplication
  • 3. •Dynamic Programming is an algorithm design method that can be used when the solution to a problem may be viewed as the result of a sequence of decisions. •Dynamic programming (usually referred to as DP ) is a very powerful technique to solve a particular class of problems. It demands very elegant formulation of the approach and simple thinking and the coding part is very easy.
  • 4.  Example binary search trees 3,7,9,12 3 7 12 9 (a) (b) 9 3 7 12 12 3 7 9 (c) 12 3 7 9 (d)
  • 5. 7 -5  n identifiers : a1 <a2 <a3 <…< an Pi , 1≤i≤n : the probability that ai is searched. Qi , 0≤i≤n : the probability that x is searched where ai < x < ai+1 (a0 =-∞, an+1 =∞). 1 01 =+ ∑∑ == n i i n i i QP
  • 6. 7 -6  Let C(i, j) denote the cost of an optimal binary search tree containing ai ,…,aj .  The cost of the optimal binary search tree with ak as its root : ak a1 ...a k-1 ak+1 ...a n P 1 ...P k-1 Q 0 ...Q k-1 P k+1 ...P n Q k ...Q n C(1,k-1) C(k+1,n) ( ) ( ) ( ) ( )             +++++      −++++= ∑∑ += − = ≤≤ n1,kCQPQ1k1,CQPQPminn)C(1, n 1km mmk 1k 1m mm0k nk1
  • 7. 7 -7 ( ) ( ) ( ) ( ) ( ) ( ) ( )       +++++−=          +++++          −++++= ∑ ∑ ∑ = ≤≤ += − = ≤≤ j im mm1-i jki j 1km mmk 1k im mm1-ik jki QPQj1,kC1ki,Cmin j1,kCQPQ 1ki,CQPQPminj)C(i, ak ai ...ak-1 ak+1 ...aj Pi...Pk-1 Qi-1...Qk-1 Pk+1...Pj Qk ...Qj C(i,k-1) C(k+1,j)
  • 8. 8  Given: A set S of n items, with each item i having  wi - a positive weight  bi - a positive benefit  Goal: Choose items with maximum total benefit but with weight at most W.  If we are not allowed to take fractional amounts, then this is the 0/1 knapsack problem.  In this case, we let Tdenote the set of items we take  Objective: maximize  Constraint: ∑∈Ti ib ∑∈ ≤ Ti i Ww
  • 9. 9  Recall the definition of B[k,w]  Since B[k,w] is defined in terms of B[k−1,*], we can use two arrays of instead of a matrix  Running time: O(nW).  Not a polynomial-time algorithm since W may be large  This is a pseudo-polynomial time algorithm Algorithm 01Knapsack(S, W): Input: set S of n items with benefit bi and weight wi; maximum weight W Output: benefit of best subset of S with weight at most W let A and B be arrays of length W + 1 for w ← 0 to W do B[w] ← 0 for k ← 1 to n do copy array B into array A for w ← wk to W do if A[w−wk] + bk > A[w] then B[w] ← A[w−wk] + bk return B[W]    +−−− >− = else}],1[],,1[max{ if],1[ ],[ kk k bwwkBwkB wwwkB wkB
  • 10. 7 -10  n matrices A1, A2, …, An with size p0× p1, p1× p2, p2× p3, …, pn-1× pn To determine the multiplication order such that # of scalar multiplications is minimized.  To compute Ai× Ai+1, we need pi-1pipi+1 scalar multiplications. e.g. n=4, A1: 3 × 5, A2: 5 × 4, A3: 4 × 2, A4: 2 × 5 ((A1 × A2) × A3) × A4, # of scalar multiplications: 3 * 5 * 4 + 3 * 4 * 2 + 3 * 2 * 5 = 114 (A1 × (A2 × A3)) × A4, # of scalar multiplications: 3 * 5 * 2 + 5 * 4 * 2 + 3 * 2 * 5 = 100 (A1 × A2) × (A3 × A4), # of scalar multiplications: 3 * 5 * 4 + 3 * 4 * 5 + 4 * 2 * 5 = 160
  • 11. 7 -11  Let m(i, j) denote the minimum cost for computing Ai× Ai+1× … × Aj  Computation sequence :  Time complexity : O(n3 ) { } jiif jiif pppj)1,m(kk)m(i,min 0 j)m(i, jk1i 1-jki < =     +++ = − ≤≤