This preview shows pages 1–9. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Algorithms L15.1 Professor Ashok Subramanian L ECTURE 15 Dynamic Programming Longest common subsequence Optimal substructure Overlapping subproblems Algorithms Algorithms L15.2 Dynamic programming Design technique, like divideandconquer. Example: Longest Common Subsequence (LCS) Given two sequences x [1 . . m ] and y [1 . . n ] , find a longest subsequence common to them both. Algorithms L15.3 Dynamic programming Design technique, like divideandconquer. 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 Algorithms L15.4 Dynamic programming Design technique, like divideandconquer. 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 Algorithms L15.5 Dynamic programming Design technique, like divideandconquer. 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 Algorithms L15.6 Bruteforce LCS algorithm Check every subsequence of x [1 . . m ] to see if it is also a subsequence of y [1 . . n ] . Algorithms L15.7 Bruteforce 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 subsequences of x (each bitvector of Worstcase running time = O ( n 2 ) Algorithms L15.8 Towards a better algorithm Simplification: 1. Look at the length of a longestcommon subsequence....
View Full
Document
 Spring '11
 k.v.arya
 Algorithms, C Programming

Click to edit the document details