Recall & Review
beginner Click to reveal answer
What is the Longest Common Subsequence (LCS)?
LCS is the longest sequence that appears in the same relative order in two sequences, but not necessarily contiguously.
intermediate Click to reveal answer
How does the LCS dynamic programming approach work?
It builds a 2D table where each cell stores the length of LCS for prefixes of the two sequences, using previous results to find the current one.
beginner Click to reveal answer
What is the time complexity of the classic LCS algorithm using dynamic programming?
The time complexity is O(m * n), where m and n are the lengths of the two sequences.
beginner Click to reveal answer
In LCS, what does it mean if characters at current indices match?
If characters match, add 1 to the LCS length from previous indices and move diagonally in the DP table.
intermediate Click to reveal answer
How do you reconstruct the LCS string from the DP table?
Start from the bottom-right cell and move backwards: if characters match, add to result; else move in direction of larger value.
What does LCS stand for?
✗ Incorrect
LCS stands for Longest Common Subsequence.
What is the main idea behind the dynamic programming solution for LCS?
✗ Incorrect
The DP solution builds a table storing LCS lengths for all prefix pairs.
If characters at current indices do not match, what do you do in the DP table?
✗ Incorrect
If characters don't match, take the max value from left or top cell in the DP table.
What is the space complexity of the classic LCS DP solution?
✗ Incorrect
The classic DP solution uses O(m * n) space for the table.
Which of these is true about the LCS?
✗ Incorrect
LCS preserves the order of characters in both sequences but not necessarily contiguous.
Explain how to use dynamic programming to find the Longest Common Subsequence between two strings.
Think about building solutions for smaller parts first.
You got /5 concepts.
Describe the process to reconstruct the actual LCS string after computing the DP table.
Trace back through the table to find the sequence.
You got /5 concepts.
