next up previous
Next: Up: Previous:

Dynamic Programming

1. Optimal Substructure.



Define: Given X = \(\langle x_1, .., x_m \rangle\), the ith prefix of X, i = 0, .., m, is \(X_i \;=\; \langle x_1, .., x_i \rangle \). X0 is empty.

Theorem 16.1

Let X = \(\langle x_1, .., x_m \rangle\) and Y = \(\langle y_1, .., y_n \rangle\) be sequences, and Z = \(\langle z_1, .., z_k \rangle\) be any LCS of X and Y.

1.
If xm = yn, then zk = xm = yn and Zk-1 is an LCS of Xm-1 and Yn-1.



2.
If \(x_m \neq y_n\), then \(z_k \neq x_m\) implies that Z is an LCS of Xm-1 and Y.



3.
If \(x_m \neq y_n\), then \(z_k \neq y_n\) implies that Z is an LCS of X and Yn-1.

Thus the LCS problem has optimal substructure.


next up previous
Next: Up: Previous: