Thus, we see that there are two longest increasing subsequences of length 4, one starting at 9,
namely 9, 12, 16, 18 and one starting at 3, 12, 16, 18.
Remarks. The computation of the matrix Len[0:n – 1, 0:n – 1] determines all the starting
points of longest increasing subsequences. However, there may be more than one longest
9.18 Consider the knapsack problem with objects{b0, b1, … , bn-1} having positive integer
values v0, v1, … , vn-1, weights w0, w1, … , wn-1, and capacity C. For convenience, we assume
(1) Val[i, j] = Val[i – 1, j] for 0 ≤ j < wi
= max{ vi + Val[i – 1, j – wi ], Val[i – 1, j] } for wi ≤ j ≤ C ,
(2) B[i, j] = B[i – 1, j] if Val[i, j] = Val[i – 1, j],
= i otherwise
init. cond. B[0, j] = – 1 for j < w0, B[0, j] = 0 for w0 ≤ j ≤ C