The subset-sum problem is defined as follows. Given a set of n positive integers,
S={\(a_{1},a_{2},...,a_{n}\)} and positive integer W, is there a subset of S whose
elements sum to W? A dynamic program for solving this problem uses a
2-dimensional Boolean array, X, with n rows and W+1 columns. X[i,j], \(1\leq i\leq n\), \(0\leq j \leq W\), is TRUE if and only if there is a subset of {\(a_{1},a_{2},...,a_{i}\)}whose elements sum to j. Which of the following is valid for \(2\leq i\leq n\) and \(a_{i} \leq j \leq W\)?
- A\(X[i,j]=X[i-1,j]\vee X[i,j-a_{i}]\)
- B\(X[i,j]=X[i-1,j]\vee X[i-1,j-a_{i}]\)
- C\(X[i,j]=X[i-1,j]\wedge X[i,j-a_{i}]\)
- D\(X[i,j]=X[i-1,j]\wedge X[i-1,j-a_{i}]\)