digraph {
S [label=Start shape=oval]
I1 [label="Define sequences x and y" shape=parallelogram]
I2 [label="Initialize LCS table
(size (m+1) x (n+1))" shape=parallelogram]
I3 [label="Set LCS[0][j] = 0 for all j
Set LCS[i][0] = 0 for all i" shape=parallelogram]
L [label="Loop i from 1 to m
Loop j from 1 to n" shape=diamond]
C [label="Compare x[i] and y[j]" shape=diamond]
T [label="LCS[i][j] = 1 + LCS[i-1][j-1]" shape=rectangle]
F [label="LCS[i][j] = max(LCS[i-1][j], LCS[i][j-1])" shape=rectangle]
R [label="Return LCS[m][n]" shape=parallelogram]
E [label=End shape=oval]
S -> I1
I1 -> I2
I2 -> I3
I3 -> L
L -> C [label="For each i, j"]
C -> T [label="If x[i] == y[j]"]
C -> F [label=Else]
T -> L [label="Next iteration"]
F -> L [label="Next iteration"]
L -> R [label="Loop complete"]
R -> E
}