Dynamic programming longest common subsequence
Download
1 / 13

Dynamic Programming (Longest Common Subsequence) - PowerPoint PPT Presentation


  • 113 Views
  • Uploaded on

Dynamic Programming (Longest Common Subsequence). Subsequence. String Z is a subsequence of string X if Z’s characters appear in X following the same left-to-right order. X = < A, B, C, T, D, G, N, A, B > Z = < B, D, A >. Longest Common Subsequence (LCS).

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Dynamic Programming (Longest Common Subsequence)' - lin


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Dynamic programming longest common subsequence

Dynamic Programming(Longest Common Subsequence)


Subsequence
Subsequence

  • String Z is a subsequence of string X if Z’s characters appear in X following the same left-to-right order

X = < A, B, C, T, D, G, N, A, B >

Z = < B, D, A >


Longest common subsequence lcs
Longest Common Subsequence (LCS)

  • String Z is a common subsequence of strings X and Y if Z’s characters appear in both X & Y following the same left-to-right order

X = < A, B, C, T, B, D, A, B >

Y = < B, D, C, A, B, A >

  • < B, C, A > is a common subsequence of both X and Y.

  • < B, C, B, A > or < B, C, A, B > is the Longest Common Subsequence (LCS) of X and Y.

LCS is used to measure the similarity between two strings X and Y. The longer the LCS , the more similar X and Y


Lcs problem definition
LCS Problem Definition

  • We are given two sequences

    • X= <x1,x2,...,xm>,and

    • Y = <y1,y2,...,yn>

  • We need to find the LCS between X and Y

Very common in DNA sequences




Recursive nature of lcs
Recursive Nature of LCS

  • Implications of Theorem 15.1


Recursive equation
Recursive Equation

  • Input X = <x1, x2, …., xm>

    Y = <y1, y2, ………, yn>

  • Assume C[i, j] is the LCS for the first i positions in X with the first j positions in Y

    • C[i,j] = LCS(<x1, x2, …., xi>, <y1, y2, ………, yj>)

Our goal is to compute C[m,n]


Dynamic programming for lcs
Dynamic Programming for LCS

Initialization step


Dynamic programming for lcs1
Dynamic Programming for LCS

If matching, go diagonal


Dynamic programming for lcs2
Dynamic Programming for LCS

Else select the larger of top or left


Dynamic programming for lcs3
Dynamic Programming for LCS

Note that array c  keeps track of the cost,

Array b  keeps track of the parent (to backtrack)



ad