0% found this document useful (0 votes)
96 views38 pages

Unit 3

Dynamic programming is an algorithmic technique that solves problems by breaking them down into smaller subproblems. It is based on the principle of optimality - that optimal solutions can be constructed from optimal solutions of subproblems. The steps are to verify the principle holds, set up recurrence relations, solve the relations to find the optimal solution, and perform backtracking to construct the solution. Examples provided include all pairs shortest paths, traveling salesperson problem, optimal binary search trees, and flow shop scheduling.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
96 views38 pages

Unit 3

Dynamic programming is an algorithmic technique that solves problems by breaking them down into smaller subproblems. It is based on the principle of optimality - that optimal solutions can be constructed from optimal solutions of subproblems. The steps are to verify the principle holds, set up recurrence relations, solve the relations to find the optimal solution, and perform backtracking to construct the solution. Examples provided include all pairs shortest paths, traveling salesperson problem, optimal binary search trees, and flow shop scheduling.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 38

Dynamic Programming

UNIT-3
Introduction

Dynamic programming is based on the principle of


optimality .
The principle of optimality states that no matter
whatever the initial state and initial decision are, the
remaining decision sequence must constitute an
optimal decision sequence with regard to the state
resulting from the first decision.
The principle implies that an optimal decision
sequence is comprised of optimal decision
subsequences.
Since the principle of optimality may not hold for
some formulations of some problems, it is necessary
to verify that it does hold for the problem being
solved. Dynamic programming cannot be applied
when this principle does not hold.
The steps in a dynamic programming solution are:
 Verify that the principle of optimality holds
 Set up the dynamic-programming recurrence equations
 Solve the dynamic-programming recurrence equations
for the value of the optimal solution.
 Perform a trace back step in which the solution itself is
constructed.
All pairs shortest paths

In the all pairs shortest path problem, we are to find


a shortest path between every pair of vertices in a
directed graph G. That is, for every pair of vertices (i,
j), we are to find a shortest path from i to j as well as
one from j to i.
When no edge has a negative length, the all-pairs
shortest path problem may be solved by using
Dijkstra‟s greedy single source algorithm n times,
once with each of the n vertices as the source vertex.
Algorithm
Example
Step 1 :Solving the equation for k = 1
Step 2: Solving the equation for, K = 2
Step 3: Solving the equation for k = 3
TRAVELLING SALESPERSON PROBLEM
Example
OPTIMAL BINARY SEARCH TREE
OPTIMAL BINARY SEARCH TREE
Example
Example
FLOW SHOP SCHEDULING

Often the processing of a job requires the


performance of several distinct tasks.
Computer programs run in a multiprogramming
environment are input and then executed
Following the execution, the job is queued for output
and the output eventually printed.
In a general flow shop we may have n job search
requiring m tasks

to be performed.
Two possible schedules:
A non-preemptive schedule is a schedule in which
the processing of a task on any processor is not
terminated until the task is complete.
A schedule for which this need not be true is called
preemptive.
Scheduling rule for optimal solution

You might also like