DAA - Week 11 - Lecture 1 - Longest Common Subsequence
DAA - Week 11 - Lecture 1 - Longest Common Subsequence
Then, common subsequences are {B, C}, {C, D, A, C}, {D, A, C}, {A, A, C}, {A, C}, {C, D}, ...
// Building the mtrix in bottom-up way else if (LCS_table[i - 1][j] > LCS_table[i][j - 1])
IF both characters are different then select the maximum value between immediate left and upper cells.
IF both characters are same then select the immediate upper diagonal value and add 1 to it and write in the current cell.
Y - b a b b a b
- 0 0 0 0 0 0 0
X a 0 0 1 1 1 1 1
b 0 1 1 2 2 2 2
a 0 1 2 2 2 3 3
a 0 1 2 2 2 3 3
b 0 1 2 3 3 3 4
a 0 1 2 3 3 4 4