lec15 - Introduction to Algorithms 6.046J/18.401J LECTURE...

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

View Full Document Right Arrow Icon
November 7, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L15.1 Introduction to Algorithms 6.046J/18.401J L ECTURE 15 Dynamic Programming Longest common subsequence Optimal substructure Overlapping subproblems Prof. Charles E. Leiserson
Background image of page 1

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

View Full DocumentRight Arrow Icon
November 7, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L15.2 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
November 7, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L15.3 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
November 7, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L15.4 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 :ABCBDAB y :B D C A B A “a” not “the”
Background image of page 4
November 7, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L15.5 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 :ABCBDAB 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
November 7, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L15.6 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
November 7, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L15.7 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
November 7, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L15.8 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 10/19/2010 for the course CS 477 taught by Professor Gewali during the Spring '08 term at University of Nevada, Las Vegas.

Page1 / 31

lec15 - Introduction to Algorithms 6.046J/18.401J LECTURE...

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