Dynamic Programming
Dynamic Programming
Introduction
Assembly line scheduling
Assembly line scheduling
Assembly line scheduling
Optimal Substructure
Recursive solution
Assembly line scheduling
Computing the fastest time
Computing the fastest time
Constructing the fastest way
Motivation
• We often want to compare the DNA of two or
more organisms.
• Expressed as a string over the set {A, C, G, T}
• S1=ACCGGTA………..• S1=ACCGGTA………..
• S2=ACCGCTA…………
• How similar are these two strands?
• How long is the longest-common-
subsequence?
Longest common subsequence
Optimal Substructure
Big Idea: The LCS of two sequences contains within it
an LCS of the prefixes of the two sequences.
Recursive formulation
Example
Compute the length of the Optimal
solution
Tables computed by LCS-Length
Constructing the LCS