GATE / CS ARCHIVE

GATE CSE 2008 / QUESTION 81

Subset-sum answer table cell

Algorithms · Dynamic Programming · Full GATE CSE 2008 paper

GATE 2008, Q81 2 marks · MCQ
Report issue

Dynamic Programming

Question 81, GATE 2008: Given positive integers S={a₁,…,aₙ} and target W>0, a subset-sum dynamic program uses Boolean X with n rows and W+1 columns. X[i,j] is true iff some subset of {a₁,…,aᵢ} sums to j, for 1≤i≤n and 0≤j≤W. Which entry, if TRUE, implies there is a subset summing to W? (This preserves the printed one-way wording.)

(A) X[1,W]
(B) X[n,0]
(C) X[n,W]
(D) X[n−1,n]
Question 81, GATE 2008: Given positive integers S={a₁,…,aₙ} and target W>0, a subset-sum dynamic program uses Boolean X with n rows and W+1 columns. X[i,j] is true iff some subset of {a₁,…,aᵢ} sums to j, for 1≤i≤n and 0≤j≤W. Which entry, if TRUE, implies there is a subset summing to W? (This preserves the printed one-way wording.)

(A) X[1,W]
(B) X[n,0]
(C) X[n,W]
(D) X[n−1,n]
Question 81, GATE 2008: Given positive integers S={a₁,…,aₙ} and target W>0, a subset-sum dynamic program uses Boolean X with n rows and W+1 columns. X[i,j] is true iff some subset of {a₁,…,aᵢ} sums to j, for 1≤i≤n and 0≤j≤W. Which entry, if TRUE, implies there is a subset summing to W? (This preserves the printed one-way wording.)

(A) X[1,W]
(B) X[n,0]
(C) X[n,W]
(D) X[n−1,n]
Tap to enlarge
Your answer
Answer & solution

Answer: C intended; A also satisfies the literal implication (no official key was published)

1. By the definition of X, X[n,W] is true if and only if a subset of all n inputs sums to W. Therefore C is the terminal decision cell intended by the algorithm.
2. However, the printed wording asks only which TRUE entry implies the existence of a subset summing to W. X[1,W] being true also implies that fact, since {a1} is contained in the full set.
3. B is always true via the empty subset and D concerns sum n rather than W. Thus A and C both satisfy the literal one-way implication; C alone is necessary and sufficient for the full problem.

Original paper, page 17