CARVIEW |
Select Language
HTTP/2 200
content-type: text/html; charset=utf-8
date: Sat, 23 Aug 2025 03:57:55 GMT
permissions-policy: interest-cohort=()
strict-transport-security: max-age=31536000; includeSubDomains
server: nginx
cache-control: s-maxage=63566, max-age=0
x-powered-by: Next.js
etag: "wkfvhdxie59e4x"
content-encoding: gzip
x-xss-protection: 1; mode=block
x-content-type-options: nosniff
referrer-policy: no-referrer-when-downgrade
content-security-policy: default-src 'self' http: https: ws: wss: data: blob: 'unsafe-eval' 'unsafe-inline'; frame-ancestors 'self';
vary: Accept-Encoding
x-cache: Hit from cloudfront
via: 1.1 29c4071d54ad6f88b4c9a40d8f1b2124.cloudfront.net (CloudFront)
x-amz-cf-pop: BOM78-P9
x-amz-cf-id: yqcym7yZDpmccK7-31CCJIfChrlpW1x-tOIvLUEFwOsW2nzk5DZLJQ==
age: 23308
GATE | CS | 2009 | Algorithms | Dynamic Programming | Question 53
Interview Preparation
- Interview Preparation For Software Developers
- Must Coding Questions - Company-wise
- Must Do Coding Questions - Topic-wise
- Company-wise Practice Problems
- Company Preparation
- Competitive Programming
- Software Design-Patterns
- Company-wise Interview Experience
- Experienced - Interview Experiences
- Internship - Interview Experiences
GATE | CS | 2009 | Algorithms | Dynamic Programming | Question 53
Last Updated :
Discuss
Comments
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]
expr1 ≡ l(i-1, j) + 1
expr1 ≡ l(i, j-1)
expr2 ≡ max(l(i-1, j), l(i, j-1))
expr2 ≡ max(l(i-1,j-1),l(i,j))
Share your thoughts in the comments

GeeksforGeeks
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy