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

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

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

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

View Full Document
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.
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”

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

View Full Document
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”
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

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

View Full Document
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 ] .
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.

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

View Full Document
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.
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
Ask a homework question - tutors are online