The subset-sum problem is defined as follows. Given a set of positive integers, , and positive integer , is there a subset of whose elements sum to ? A dynamic program for solving this problem uses a Boolean array, , with rows and columns. , is TRUE, if and only if there is a subset of whose elements sum to .
Which entry of the array , if TRUE, implies that there is a subset whose elements sum to ?
View worked solution
Answer: C
According to the problem definition, the entry is defined as:
- (Row index): Represents the subset of the first elements, i.e., .
- (Column index): Represents the target sum.
We want to determine if there is a subset of the entire set (which contains all elements) that sums to the target value .
- To consider the entire set of elements, we must set .
- To check for the target sum , we must set .
Thus, the entry being TRUE indicates that there exists a subset of the entire set whose elements sum to .
Therefore, the correct option is C.
Free practice · Your answers on this page are not saved.
