→ strictly increasing sequence일 때. LCS라고 할 수 있다.
Analysis
X = <x1, x2, ... , xn>
Y = <y1, y2, ..., yn>
i-th prefix
Case1
LCS(X, Y, i, j)
if X[i] = Y[j]
then c[i,j] <- LCS(X, Y, i-1, j-1) + 1
else c[i,j] <- max{LCS(X, Y, i-1, j), LCS(X, Y, i, j-1)}
return c[i,j]
LCS-Length(X,Y)
m<-length[X]; n<-length[Y]
for i<-1 to m c[i,0]<-0
for j<-0 to n c[0,j]<-0
for j<-1 to n
for i<-1 to m
if X[i]=Y[j]
then c[i,j]<-c[i-1,j-1]+1; b[i,j] <- 왼쪽 위 화살표
else if c[i,j-1]>= c[i-1,j]
then c[i,j]<-c[i,j-1]; b[i,j] <- 위 화살표
else c[i,j]<-c[i-1,j]; b[i,j] <- 왼쪽 화살표
return c and b
Print-LCS(b, X, i, j)
if i=0 or j=0
then return
if b[i,j] = "왼쪽 위 화살표"
then PRINT-LCS(b,X,i-1,j-1)
print xi
elseif b[i,j] = "위 화살표"
then PRINT-LCS(b,X,j-1,j)
else PRINT-LCS(b,X,i,i-1)