Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Pick a random set of 10 integers ranging from 3 to 20. Use the algorithm above to Solve the subset sum problem for your set
Pick a random set of 10 integers ranging from 3 to 20. Use the algorithm above to Solve the subset sum problem for your set and the target 37. JAVA
Notation: If L is a list of positive integers from S (i.e. a sub-list) and x is member of S, then we let L+x denote the augmented sub-list derived from L by adding (i.e., appending) x to the set L For example, if L = {4, 1, 7} then L + 2-4, 1,7, 2} sum(L) wll mean the sum of elements in set L. So, sum(14,1,7-12 Col will be some collection of sub-lists. For example, if S-(4, 1,7), Col might be (0,(4, 1), (4,7))(we count the empty subset, as a list in the collection if we want it there). An exact, but not particularly fast, algorithm to find the subset L' with the sum(L) as large as possible but less than or equal to t is as follows: Initialize the collection Col with one sub-list: the empty sub-list. Loop over all elements x in S Loop over all subsets, L, that are already members of Co if sum(L)+xs t, add the sub-list L +x to Col - if sum(L)+xt, break from both loops! Of all the subsets that end up in Col, find the sub-list L' with the largest sum) The set L' in the last step is the subset which has the largest sum, without going over the target, tStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started