Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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, t

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

XML Data Management Native XML And XML Enabled Database Systems

Authors: Akmal Chaudhri, Awais Rashid, Roberto Zicari, John Fuller

1st Edition

0201844524, 978-0201844528

More Books

Students also viewed these Databases questions