{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lecture15

# lecture15 - Introduction to Algorithms...

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

Introduction to Algorithms 6.046J/18.401J/SMA5503 Lecture 15 Prof. Charles E. Leiserson

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

View Full Document
Introduction to Algorithms Day 26 L15.2 © 2001 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 : A B C B D A B y : B D C A B A “a” not “the” BCBA = LCS( x , y ) functional notation, but not a function
Introduction to Algorithms Day 26 L15.3 © 2001 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.

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

View Full Document
Introduction to Algorithms Day 26 L15.4 © 2001 by Charles E. Leiserson Towards a better algorithm Simplification: 1. Look at the length of a longest-common subsequence. 2. Extend the algorithm to find the LCS itself. Strategy: Consider prefixes of x and y .
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}