15. Dynamic Programming - PowerPoint PPT Presentation

1 / 36
About This Presentation
Title:

15. Dynamic Programming

Description:

Longest common subsequence. 2 ... Unweighted longest simple path: Find a simple path from u to v consisting ... (or sequence): A list of characters from an ... – PowerPoint PPT presentation

Number of Views:190
Avg rating:3.0/5.0
Slides: 37
Provided by: win83
Category:

less

Transcript and Presenter's Notes

Title: 15. Dynamic Programming


1
15. Dynamic Programming
2
Contents
  • Dynamic Programming
  • Assembly-line scheduling
  • Matrix-chain multiplication
  • Elements of dynamic programming
  • Longest common subsequence

3
Dynamic Programming
  • Dynamic programming solves a problem by
    partitioning the problem into subproblems.
  • The subproblems are independent
    divide-and-conquer method.
  • The subproblems are not independent dynamic
    programming.
  • A dynamic programming algorithm solves every
    subproblem just once and saves its answer in a
    table and then reuse it.

divide-and-conquer
Dynamic Programming
4
Dynamic Programming
  • Dynamic programming is typically to solve
    optimization problems.
  • Optimization problems
  • There can be many possible solutions.
  • Each solution has a value.
  • We find a solution with the optimal (minimum or
    maximum) value.
  • Such a solution is called an optimal solution to
    the problem.
  • Shortest path example

5
Dynamic Programming
  • The development of a dynamic-programming
    algorithm can be broken into a sequence of four
    steps.
  • Characterize the structure of an optimal
    solution.
  • Recursively define the value of an optimal
    solution.
  • Compute the value of an optimal solution in a
    bottom-up fashion.
  • Construct an optimal solution from computed
    information.

6
ASSEMBLY-LINE SCHEDULING
  • ti,j time to transfer from assembly line 1?2or
    2?1
  • ai,j processing time in each station
  • e1, e2 time to enter assembly lines 1 and 2
  • x1, x2 time to exit assembly lines 1 and 2
  • The problem Determine the fastest assembly time

7
Assembly-line scheduling
  • Brute-force approach
  • Enumerate all possible ways and find a fastest
    way.
  • There are 2n possible ways Too many.

8
Assembly-line scheduling
  • Step 1 The structure of the fastest way through
    the factory
  • Optimal substructure
  • A property that an optimal solution to a problem
    contains within in and optimal solution to
    subproblem.
  • The fastest way through station Si,j contains the
    fastest way through either S1,j-1 or S2,j-1.

9
Assembly-line scheduling
  • Step 2 A recursive solution

10
Assembly-line scheduling
  • Step 3 Computing the fastest times

11
Assembly-line scheduling
  • Running time
  • We can compute the fastest time in T(n) time.

12
Assembly-line scheduling
  • Step 4 Constructing the fastest way through the
    factory
  • The lij values help us trace a fastest way.

13
Matrix-chain multiplication
  • A product of matrices is fully parenthesized if
    it is either a single matrix, or a product of two
    fully parenthesized matrix product, surrounded by
    parentheses.
  • Let A be a p
Write a Comment
User Comments (0)
About PowerShow.com