lecture_12

lecture_12 - Introduction to Algorithms 6.046J/18.401J...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
Introduction to Algorithms 6.046J/18.401J Prof. Charles E. Leiserson L ECTURE 12 Dynamic programming Longest common subsequence Optimal substructure Overlapping subproblems
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Introduction to Algorithms October 25, 2004 L12.2 © 2001–4 by Charles E. Leiserson Dynamic programming Design technique, like divide-and-conquer. Example: Longest Common Subsequence (LCS) Given two sequences x [1 . . m ] and y [1 . . n ] , find a longest subsequence common to them both.
Background image of page 2
Introduction to Algorithms October 25, 2004 L12.3 © 2001–4 by Charles E. Leiserson Dynamic programming Design technique, like divide-and-conquer. Example: Longest Common Subsequence (LCS) Given two sequences x [1 . . m ] and y [1 . . n ] , find a longest subsequence common to them both. “a” not “the”
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Introduction to Algorithms October 25, 2004 L12.4 © 2001–4 by Charles E. Leiserson Dynamic programming Design technique, like divide-and-conquer. Example: Longest Common Subsequence (LCS) Given two sequences x [1 . . m ] and y [1 . . n ] , find a longest subsequence common to them both. x : AB C BDAB y :B D C A B A “a” not “the”
Background image of page 4
Introduction to Algorithms October 25, 2004 L12.5 © 2001–4 by Charles E. Leiserson Dynamic programming Design technique, like divide-and-conquer. Example: Longest Common Subsequence (LCS) Given two sequences x [1 . . m ] and y [1 . . n ] , find a longest subsequence common to them both. x : AB C BDAB y :B D C A B A “a” not “the” BCBA = LCS( x , y ) functional notation, but not a function
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Introduction to Algorithms October 25, 2004 L12.6 © 2001–4 by Charles E. Leiserson Brute-force LCS algorithm Check every subsequence of x [1 . . m ] to see if it is also a subsequence of y [1 . . n ] .
Background image of page 6
Introduction to Algorithms October 25, 2004 L12.7 © 2001–4 by Charles E. Leiserson Brute-force LCS algorithm Check every subsequence of x [1 . . m ] to see if it is also a subsequence of y [1 . . n ] . Analysis Checking = O ( n ) time per subsequence. 2 m subsequences of x (each bit-vector of length m determines a distinct subsequence of x ). Worst-case running time = O ( n 2 m ) = exponential time.
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Introduction to Algorithms October 25, 2004 L12.8 © 2001–4 by Charles E. Leiserson Towards a better algorithm Simplification: 1. Look at the length of a longest-common subsequence.
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/10/2008 for the course CSE 6.046J/18. taught by Professor Piotrindykandcharlese.leiserson during the Fall '04 term at MIT.

Page1 / 31

lecture_12 - Introduction to Algorithms 6.046J/18.401J...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online