Optimal Substructure Theorem
Let
and
be sequences, and let
be any LCS of
X
and
Y
.
1. If
x
m
=
y
n
, then
z
k
=
x
m
=
y
n
and
Z
k
-1
is an LCS of
X
m
-1
and
Y
n
-1
.
2. If
, then
implies that
Z
is an LCS of
X
m
-1
and
Y
.
3. If
, then
implies that
Z
is an LCS of
X
and
Y
n
-1
.
Next:
Recursive Formula
Up:
LONGEST COMMON SUBSEQUENCE
Previous:
Algorithmic Ideas