Unformatted text preview: t Graph Alignment: Dynamic Programming Every path in the edit
graph corresponds to
an alignment: Dynamic Programming Example Dynamic Programming Example Initialization: 0th row
and 0th column all
zeroes. Alignment: Backtracking
Arrows
show where the score
originated from. Backtracking Example
Find a match in row and column 2.
i=2, j=2,5 is a match (T). if from the top j=2, i=4,5,7 is a match (T). if from the left Since vi = wj, si,j = si1,j1 +1 if vi = wj s2,2
s2,5
s4,2
s5,2
s7,2 =
=
=
=
= [s1,1
[s1,4
[s3,1
[s4,1
[s6,1 =
=
=
=
= 1]
1]
1]
1]
1] +
+
+
+
+ 1
1
1
1
1 10 Backtracking Example LCS Algorithm The corresponding
alignment: LCS(v,w)
for i 1 to
si,0 0
for j 1 to
s0,j 0
for i 1 to
for j 1 n Runtime: O(nm)
Memory: O(nm) m
n
to m si1,j
si,j1
si1,j1 + 1, if vi = wj
if si,j = si1,j
bi,j if si,j = si,j1
if si,j = si1,j1 + 1
return (sn,m, b)
si,j max Now What? Printing LCS: Backtracking • LCS(v,w) created the
alignment grid PrintLCS(b,v,i,j)
1.
if i = 0 o r j = 0
2.
return
3.
if bi,j = “
“
4.
PrintLCS(b,v,i1,j1)
5.
print vi
6.
else
7.
if bi,j = “
“
8.
PrintLCS(b,v,i1,j)
9.
else
10.
PrintLCS(b,v,i,j1) • To read the best
alignment: Follow
the arrows
backwards from sink 11...
View
Full
Document
This note was uploaded on 02/10/2014 for the course CS 548 taught by Professor Asabenhur during the Spring '12 term at Colorado State.
 Spring '12
 AsaBenHur
 Algorithms

Click to edit the document details