0% found this document useful (0 votes)
10 views1 page

LCS Code Implementation Steps

The document outlines a flowchart for computing the Longest Common Subsequence (LCS) between two sequences x and y. It details the initialization of the LCS table, the comparison of elements, and the recursive calculation of LCS values. The process concludes with returning the length of the LCS after completing the iterations.

Uploaded by

tushar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views1 page

LCS Code Implementation Steps

The document outlines a flowchart for computing the Longest Common Subsequence (LCS) between two sequences x and y. It details the initialization of the LCS table, the comparison of elements, and the recursive calculation of LCS values. The process concludes with returning the length of the LCS after completing the iterations.

Uploaded by

tushar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

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
}

You might also like