1 / 9

Dynamic Programming

Dynamic Programming. Csc 487/687 Computing for Bioinformatics. Subsequence. A subsequence of a given sequence is just the given sequence with some elements (possible none) left out.

Télécharger la présentation

Dynamic Programming

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Dynamic Programming Csc 487/687 Computing for Bioinformatics

  2. Subsequence • A subsequence of a given sequence is just the given sequence with some elements (possible none) left out. • Given a sequence X = <x1,x2,…,xm>, another sequence Z = <z1,z2,…,zk> is a subsequence of X if there exists a strictly increasing sequence <i1,i2,…,ik> of indices of X such that for all j=1,2,…,k, we have xij = zj.

  3. Common subsequence • Given two sequences X and Y, we say that a sequence Z is a common subsequence of X and Y if Z is a subsequence of both X and Y. • Longest-common-subsequence problem(LCS) • We are given two sequences X = <x1,x2,…,xm> and Y = <y1,y2,…,yn> and wish to find a maximum length common subsequence of X and Y.

  4. How to solve it? • Brute force search?

  5. What is dynamic programming? • Divide-and-conquer algorithms? • Not independent? Subproblems share subsubproblems. • Just once and then saves its answer in a table, thereby avoiding the work of recomputing the answer every time

  6. The development of a dynamic programming algorithm • Characterize the structure of an optimal solution. • Recursively define the value of an optimal solution • Compute the value of an optimal solution in bottom-up fashion • Construct an optimal solution from computed information

  7. Optimal-substructure property • Given a sequence X = <x1,x2,…,xm>, we define the ith prefix of X, for i=0,1,…,m, as Xi = <x1,x2,…,xi> . • Optimal substructure of an LCS Let X = <x1,x2,…,xm>, Y = <y1,y2,…,yn> be sequences, and let Z = <z1,z2,…,zk> be any LCS of X and Y • If xm = yn, then zk =xm = yn and Zk-1 is an LCS of Xm-1 and Yn-1 • If xm ≠ yn, then zk ≠xm implies Zis an LCS of Xm-1 and Y. • If xm ≠ yn, then zk ≠yn implies Zis an LCS of Xand Yn-1.

  8. The cost of optimal solution • C [i, j] is the length of an LCS of the sequence Xi and Yj. if either i=0 or j=0, one of the sequences has length of 0, so the LCS has length 0. the optimal substructure of the LCS problem gives the recursive formula 0 if i=0 or j=0 c[i,j]= c[i-1, j-1]+1 if i,j>0 and xi=yj, max(c[i, j-1],c[i-1,j]) if i,j>0 and xi ≠yj,

  9. Example..

More Related