Statement for Linked Answer Questions 80 and 81: The subset-sum problem is…
GATE · 2008 · CSModified — slightly modified from the official paper; see the solution
Statement for Linked Answer Questions 80 and 81: The subset-sum problem is defined as follows. Given a set of n positive integers, S = {a₁, a₂, a₃, …, aₙ}, and a positive integer W, is there a subset of S whose elements sum to W? A dynamic program uses a 2-dimensional Boolean array X with n rows and W+1 columns. X[i,j], 1 ≤ i ≤ n, 0 ≤ j ≤ W, is TRUE if and only if a subset of {a₁,…,aᵢ} sums to j.
Question 81: Which entry of the array X, if TRUE, implies that there is a subset whose elements sum to W?
- A.
X[1, 0]
- B.
X[n, 0]
- C.
X[n, W]
- D.
X[n-1, n]
Attempted by 237 students.
Sign up free to check your answer
Sign up freeLoading lesson…