Question: Problem 2 ( 1 0 = 1 0 ) Subset Sum In the Subset Sum problem, we are given a set A = { a
Problem Subset Sum
In the Subset Sum problem, we are given a set A a a an of n nonnegative integers and another
nonnegative integer b and are asked to determine if there exists a subset of A whose sum is exactly b So
an algorithm for Subset Sum takes as input A and b and returns True if there exists a subset of A whose
sum is exactly b and False otherwise.
a Suppose you are given an algorithm to solve the Knapsack problem. Show how the Subset Sum problem
can be solved by building an instance of the Knapsack problem and then using the Knapsack algorithm.
b Here, we consider a more direct dynamic programming algorithm. Let SubsetSumi s be True if
there is a subset of a ai whose sum is s and False otherwise. Note that the Subset Sum
problem is asking to find SubsetSumn b Show that for any i and s SubsetSumi s can
be determined from the values of SubsetSumi Using this, establish a recurrence relation for
SubsetSumi s Remember to include base cases.
c Convert the recurrence of part b to a bottomup dynamic programming algorithm. Analyze its
running time.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
