Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Questions  >  A sub-sequence of a given sequence is just th... Start Learning for Free
A sub-sequence of a given sequence is just the given sequence with some elements (possibly none or all) left out. We are given two sequences X[m] and Y[n] of lengths m and n respectively, with indexes of X and Y starting from 0. We wish to find the length of the longest common sub-sequence(LCS) of X[m] and Y[n] as l(m,n), where an incomplete recursive definition for the function l(i,j) to compute the length of The LCS of X[m] and Y[n] is given below:
l(i,j) = 0, if either i=0 or j=0
= expr1, if i,j > 0 and X[i-1] = Y[j-1]
= expr2, if i,j > 0 and X[i-1] != Y[j-1] 
  • a)
    expr1 ≡ l(i-1, j) + 1
  • b)
    expr1 ≡ l(i, j-1)
  • c)
    expr2 ≡ max(l(i-1, j), l(i, j-1))
  • d)
    expr2 ≡ max(l(i-1,j-1),l(i,j))
Correct answer is option 'C'. Can you explain this answer?
Verified Answer
A sub-sequence of a given sequence is just the given sequence with som...
In Longest common subsequence problem, there are two cases for X[0..i] and Y[0..j]
1) The last characters of two strings match. 
   The length of lcs is length of lcs of X[0..i-1] and Y[0..j-1]
2) The last characters don't match.
   The length of lcs is max of following two lcs values
   a) LCS of X[0..i-1] and Y[0..j]
   b) LCS of X[0..i] and Y[0..j-1]
View all questions of this test
Most Upvoted Answer
A sub-sequence of a given sequence is just the given sequence with som...
Let's complete the recursive definition for the function l(i, j):

l(i, j) = 0, if either i = 0 or j = 0
l(i, j) = l(i - 1, j - 1) + 1, if X[i - 1] = Y[j - 1]
l(i, j) = max(l(i - 1, j), l(i, j - 1)), if X[i - 1] != Y[j - 1]

The first case states that if either sequence X or Y is empty (i = 0 or j = 0), the length of the LCS is 0.

The second case states that if the last elements of both sequences match (X[i - 1] = Y[j - 1]), we add 1 to the length of the LCS found by comparing the remaining sequences l(i - 1, j - 1).

The third case states that if the last elements of both sequences do not match (X[i - 1] != Y[j - 1]), we take the maximum length of the LCS found by either excluding the last element of X (l(i - 1, j)) or excluding the last element of Y (l(i, j - 1)).

Using this recursive definition, we can compute the length of the LCS between X[m] and Y[n] by evaluating l(m, n).
Explore Courses for Computer Science Engineering (CSE) exam

Similar Computer Science Engineering (CSE) Doubts

Top Courses for Computer Science Engineering (CSE)

A sub-sequence of a given sequence is just the given sequence with some elements (possibly none or all) left out. We are given two sequences X[m] and Y[n] of lengths m and n respectively, with indexes of X and Y starting from 0. We wish to find the length of the longest common sub-sequence(LCS) of X[m] and Y[n] as l(m,n), where an incomplete recursive definition for the function l(i,j) to compute the length of The LCS of X[m] and Y[n] is given below:l(i,j) = 0, if either i=0 or j=0= expr1, if i,j > 0 and X[i-1] = Y[j-1]= expr2, if i,j > 0 and X[i-1] != Y[j-1]a)expr1 ≡ l(i-1, j) + 1b)expr1 ≡ l(i, j-1)c)expr2 ≡ max(l(i-1, j), l(i, j-1))d)expr2 ≡ max(l(i-1,j-1),l(i,j))Correct answer is option 'C'. Can you explain this answer?
Question Description
A sub-sequence of a given sequence is just the given sequence with some elements (possibly none or all) left out. We are given two sequences X[m] and Y[n] of lengths m and n respectively, with indexes of X and Y starting from 0. We wish to find the length of the longest common sub-sequence(LCS) of X[m] and Y[n] as l(m,n), where an incomplete recursive definition for the function l(i,j) to compute the length of The LCS of X[m] and Y[n] is given below:l(i,j) = 0, if either i=0 or j=0= expr1, if i,j > 0 and X[i-1] = Y[j-1]= expr2, if i,j > 0 and X[i-1] != Y[j-1]a)expr1 ≡ l(i-1, j) + 1b)expr1 ≡ l(i, j-1)c)expr2 ≡ max(l(i-1, j), l(i, j-1))d)expr2 ≡ max(l(i-1,j-1),l(i,j))Correct answer is option 'C'. Can you explain this answer? for Computer Science Engineering (CSE) 2024 is part of Computer Science Engineering (CSE) preparation. The Question and answers have been prepared according to the Computer Science Engineering (CSE) exam syllabus. Information about A sub-sequence of a given sequence is just the given sequence with some elements (possibly none or all) left out. We are given two sequences X[m] and Y[n] of lengths m and n respectively, with indexes of X and Y starting from 0. We wish to find the length of the longest common sub-sequence(LCS) of X[m] and Y[n] as l(m,n), where an incomplete recursive definition for the function l(i,j) to compute the length of The LCS of X[m] and Y[n] is given below:l(i,j) = 0, if either i=0 or j=0= expr1, if i,j > 0 and X[i-1] = Y[j-1]= expr2, if i,j > 0 and X[i-1] != Y[j-1]a)expr1 ≡ l(i-1, j) + 1b)expr1 ≡ l(i, j-1)c)expr2 ≡ max(l(i-1, j), l(i, j-1))d)expr2 ≡ max(l(i-1,j-1),l(i,j))Correct answer is option 'C'. Can you explain this answer? covers all topics & solutions for Computer Science Engineering (CSE) 2024 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for A sub-sequence of a given sequence is just the given sequence with some elements (possibly none or all) left out. We are given two sequences X[m] and Y[n] of lengths m and n respectively, with indexes of X and Y starting from 0. We wish to find the length of the longest common sub-sequence(LCS) of X[m] and Y[n] as l(m,n), where an incomplete recursive definition for the function l(i,j) to compute the length of The LCS of X[m] and Y[n] is given below:l(i,j) = 0, if either i=0 or j=0= expr1, if i,j > 0 and X[i-1] = Y[j-1]= expr2, if i,j > 0 and X[i-1] != Y[j-1]a)expr1 ≡ l(i-1, j) + 1b)expr1 ≡ l(i, j-1)c)expr2 ≡ max(l(i-1, j), l(i, j-1))d)expr2 ≡ max(l(i-1,j-1),l(i,j))Correct answer is option 'C'. Can you explain this answer?.
Solutions for A sub-sequence of a given sequence is just the given sequence with some elements (possibly none or all) left out. We are given two sequences X[m] and Y[n] of lengths m and n respectively, with indexes of X and Y starting from 0. We wish to find the length of the longest common sub-sequence(LCS) of X[m] and Y[n] as l(m,n), where an incomplete recursive definition for the function l(i,j) to compute the length of The LCS of X[m] and Y[n] is given below:l(i,j) = 0, if either i=0 or j=0= expr1, if i,j > 0 and X[i-1] = Y[j-1]= expr2, if i,j > 0 and X[i-1] != Y[j-1]a)expr1 ≡ l(i-1, j) + 1b)expr1 ≡ l(i, j-1)c)expr2 ≡ max(l(i-1, j), l(i, j-1))d)expr2 ≡ max(l(i-1,j-1),l(i,j))Correct answer is option 'C'. Can you explain this answer? in English & in Hindi are available as part of our courses for Computer Science Engineering (CSE). Download more important topics, notes, lectures and mock test series for Computer Science Engineering (CSE) Exam by signing up for free.
Here you can find the meaning of A sub-sequence of a given sequence is just the given sequence with some elements (possibly none or all) left out. We are given two sequences X[m] and Y[n] of lengths m and n respectively, with indexes of X and Y starting from 0. We wish to find the length of the longest common sub-sequence(LCS) of X[m] and Y[n] as l(m,n), where an incomplete recursive definition for the function l(i,j) to compute the length of The LCS of X[m] and Y[n] is given below:l(i,j) = 0, if either i=0 or j=0= expr1, if i,j > 0 and X[i-1] = Y[j-1]= expr2, if i,j > 0 and X[i-1] != Y[j-1]a)expr1 ≡ l(i-1, j) + 1b)expr1 ≡ l(i, j-1)c)expr2 ≡ max(l(i-1, j), l(i, j-1))d)expr2 ≡ max(l(i-1,j-1),l(i,j))Correct answer is option 'C'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of A sub-sequence of a given sequence is just the given sequence with some elements (possibly none or all) left out. We are given two sequences X[m] and Y[n] of lengths m and n respectively, with indexes of X and Y starting from 0. We wish to find the length of the longest common sub-sequence(LCS) of X[m] and Y[n] as l(m,n), where an incomplete recursive definition for the function l(i,j) to compute the length of The LCS of X[m] and Y[n] is given below:l(i,j) = 0, if either i=0 or j=0= expr1, if i,j > 0 and X[i-1] = Y[j-1]= expr2, if i,j > 0 and X[i-1] != Y[j-1]a)expr1 ≡ l(i-1, j) + 1b)expr1 ≡ l(i, j-1)c)expr2 ≡ max(l(i-1, j), l(i, j-1))d)expr2 ≡ max(l(i-1,j-1),l(i,j))Correct answer is option 'C'. Can you explain this answer?, a detailed solution for A sub-sequence of a given sequence is just the given sequence with some elements (possibly none or all) left out. We are given two sequences X[m] and Y[n] of lengths m and n respectively, with indexes of X and Y starting from 0. We wish to find the length of the longest common sub-sequence(LCS) of X[m] and Y[n] as l(m,n), where an incomplete recursive definition for the function l(i,j) to compute the length of The LCS of X[m] and Y[n] is given below:l(i,j) = 0, if either i=0 or j=0= expr1, if i,j > 0 and X[i-1] = Y[j-1]= expr2, if i,j > 0 and X[i-1] != Y[j-1]a)expr1 ≡ l(i-1, j) + 1b)expr1 ≡ l(i, j-1)c)expr2 ≡ max(l(i-1, j), l(i, j-1))d)expr2 ≡ max(l(i-1,j-1),l(i,j))Correct answer is option 'C'. Can you explain this answer? has been provided alongside types of A sub-sequence of a given sequence is just the given sequence with some elements (possibly none or all) left out. We are given two sequences X[m] and Y[n] of lengths m and n respectively, with indexes of X and Y starting from 0. We wish to find the length of the longest common sub-sequence(LCS) of X[m] and Y[n] as l(m,n), where an incomplete recursive definition for the function l(i,j) to compute the length of The LCS of X[m] and Y[n] is given below:l(i,j) = 0, if either i=0 or j=0= expr1, if i,j > 0 and X[i-1] = Y[j-1]= expr2, if i,j > 0 and X[i-1] != Y[j-1]a)expr1 ≡ l(i-1, j) + 1b)expr1 ≡ l(i, j-1)c)expr2 ≡ max(l(i-1, j), l(i, j-1))d)expr2 ≡ max(l(i-1,j-1),l(i,j))Correct answer is option 'C'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice A sub-sequence of a given sequence is just the given sequence with some elements (possibly none or all) left out. We are given two sequences X[m] and Y[n] of lengths m and n respectively, with indexes of X and Y starting from 0. We wish to find the length of the longest common sub-sequence(LCS) of X[m] and Y[n] as l(m,n), where an incomplete recursive definition for the function l(i,j) to compute the length of The LCS of X[m] and Y[n] is given below:l(i,j) = 0, if either i=0 or j=0= expr1, if i,j > 0 and X[i-1] = Y[j-1]= expr2, if i,j > 0 and X[i-1] != Y[j-1]a)expr1 ≡ l(i-1, j) + 1b)expr1 ≡ l(i, j-1)c)expr2 ≡ max(l(i-1, j), l(i, j-1))d)expr2 ≡ max(l(i-1,j-1),l(i,j))Correct answer is option 'C'. Can you explain this answer? tests, examples and also practice Computer Science Engineering (CSE) tests.
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Explore Courses
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev