Question: I have written a dynamic programming algorithm that finds the total amount of subsets that sum up to a target value. However, I am having

I have written a dynamic programming algorithm that finds the total amount of subsets that sum up to a target value. However, I am having trouble developing a function to recover the solution (that is, print out the actual subsets).

For example, let's take the set [2,3,5,7,9] with the target 12. My algorithm calculates that there are 3 subsets. The output table is shown in the image below.

I have written a dynamic programming algorithm that finds the total amount

But, with more complicated solutions, how would I use my output table to recursively recover a solution? Any assistance is appreciated.

St 0 1 2 3 45 6 7 8 9 10 11 12 S[02 10 10 00 0 0 0 0 0 00 S[1 31 0 11 01 0 0 0 0 0 00 S[251 0 11 02 0 1 1 0 0 00 S[371 0 1 1 02 0 2112 02 S49 10 11 02 0 2 12 2 13

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!