HW 1
HW 1
Homework 1.
Due: Monday, January, 24 2021 before 8:00am via Gradescope.
[DPV] Practice Dynamic Programming Problems
Suggested reading: Chapter 6 of the book.
1
Name: 2
X = a, b, d, b, a, b, f, g, d
Y = b, e, t, f, d, b, f, a, f, r
then the answer is 4 (since, b, d, b, a is a substring of X and it is also a subsequence of Y). You do
not need to output the actual substring, just its length.
(Faster (and correct) in asymptotic O(·) notation is worth more credit.)
(a) Define the entries of your table in words. E.g., T (i) or T (i, j) is ....
2
Name: 3
3
Name: 4
Example
Input:
3 30 12
M = −12 7 −9
39 −2 15
Output: 55
Explanation: This sum comes from the path (1, 1) → (1, 2) → (2, 2) → (3, 3). The accumulated sum
is M [1][1] + M [1][2] + M [2][2] + M [3][3] = 3 + 30 + 7 + 15 = 55.
(a) Define the entries of your table in words. E.g., T (i) or T (i, j) is ....
4
Name: 5