This preview shows pages 1–2. Sign up to view the full content.
CS3230
Tutorial 9
1. Compute the longest common subsequence of
(a)
SLWOV NNDK
and
ALWGQV NBBK
.
Ans:
LWV NK
(b)
AGCGATAGC
and
ACAGATGAG
Ans:
ACGATAG
2. Show that if
X
and
Y
are two sequences starting with
a
, then the longest common
subsequence of
X
and
Y
starts with an
a
.
Ans: Consider any longest common subsequence of
X
and
Y
, say
s
1
s
2
...s
k
. Then, for
some 1
≤
r
1
< r
2
< ... < r
k
≤ 
X

and for some 1
≤
r
0
1
< r
0
2
< ... < r
0
k
≤ 
Y

,
s
i
=
X
[
r
i
] =
Y
[
r
0
i
]. If
s
1
6
=
a
, then
r
1
>
1 and
r
0
1
>
1. But then
as
1
s
2
...s
k
is also a
common subsequence of
X
and
Y
which is of length greater than
k
. A contradiction.
3. Give a counterexample to the following claims:
(a) If
X
=
X
[1]
...X
[
m
] and
Y
=
Y
[1]
...Y
[
n
], and
X
[
m
]
6
=
Y
[
n
], then the longest
common subsequence of
X
and
Y
must end in either
X
[
m
] or
Y
[
n
].
Ans: Let
X
=
abac
and
Y
=
abab
.
(b) If
X
=
X
[1]
...X
[
m
] and
Y
=
Y
[1]
...Y
[
n
], and
X
[
m
]
6
=
Y
[
n
], then the longest
common subsequence of
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview. Sign up
to
access the rest of the document.
 Fall '10
 sanjay
 Algorithms

Click to edit the document details