2023 9 The subset sum problem is defined as follows given a set B of n positive integers and an integer K | Assignment Collections

Computer Science 2023 Computer Science Assessment – Subset-sum Problem

2023 9 The subset sum problem is defined as follows given a set B of n positive integers and an integer K | Assignment Collections

9) The subset-sum problem is defined as follows: given a set of positive integers and an integer K, can you find a subset of whose elements’ summation is equal to K? Design an algorithm to solve this problem. Address its correctness and running time.

Input: set of positive integers {b1, b2,….., bnand an integer K.

Output: whether there exist such a subset of B called B’ its elements summation is equal to K.

 

B’= BA, where A = {a1, a2,…….., an} in which AB= b1a1 +b2a2 +……+ bnan. Where ai is either 0 or 1.

 

Algorithm:

– For i= 1 to 2 (We have 2n different combinations set to be checked)

1. Create all the possible combinations of Array A and do:

§  Compute Sum =

§  If Sum = K then there is a subset sum to K. This subset B’= {b1a1, b2a2,     ……, bnan}when ai representing 1.

§  return the subset B’

– Otherwise return there is no subset sum to K.

The run time is O(2n) since it needs to go through all possible subsets to find the subset that sum to K.

 

10) Suppose you have a procedure that can partition a set of positive integers into two equal weight subsets. How could you use this procedure to solve the subset-sum problem?

To solve this we use reduction. In which prove that subset-sum problem can be reduce to partition problem and visa versa.

The set of positive integers whose element summation is equal to an integer K.

Partition reduces to Subset Sum:

Calculate Sum = , which is the summation of all the given numbers. A partition  Subset Sum if K = Sum/2.

 

Subset Sum reduces to Partition:

Calculate Sum = , which is the summation of all the given numbers.

Calculate some number x= Sum – 2K. Create new set A by add x to the set B {b1, b2,….., bn {x}, where the summation now is B+x. it is possible to split the numbers in A into some subsets iff they can summing up to K:

Subset sum of B indicates partition of A means the set that adds up to Sum with x form a partition.

Partition of A indicates subset sum of B means the numbers which are put together with x must add up to K. Therefore, a partition exists iff some numbers in the B add up to K.

 

These reference could help you :

1.      Bron, C. and Kerbosch, J. “Algorithm 457: Finding All Cliques of an Undirected Graph.” Comm. ACM 16, 48-50, 1973.

2.      Tomita, E.; Tanaka, A.; and Takahashi, H. “The Worst-Case Time Complexity for Generating All Maximal Cliques and Computational Experiments.” Theor. Comput. Sci. 363, 28-42, 2006.

 

 

 

 

We give our students 100% satisfaction with their assignments, which is one of the most important reasons students prefer us to other helpers. Our professional group and planners have more than ten years of rich experience. The only reason is that we have successfully helped more than 100000 students with their assignments on our inception days. Our expert group has more than 2200 professionals in different topics, and that is not all; we get more than 300 jobs every day more than 90% of the assignment get the conversion for payment.

Place Order Now

#write essay #research paper #blog writing #article writing #academic writer #reflective paper #essay pro #types of essays #write my essay #reflective essay #paper writer #essay writing service #essay writer free #essay helper #write my paper #assignment writer #write my essay for me #write an essay for me #uk essay #thesis writer #dissertation writing services #writing a research paper #academic essay #dissertation help #easy essay #do my essay #paper writing service #buy essay #essay writing help #essay service #dissertation writing #online essay writer #write my paper for me #types of essay writing #essay writing website #write my essay for free #reflective report #type my essay #thesis writing services #write paper for me #research paper writing service #essay paper #professional essay writers #write my essay online #essay help online #write my research paper #dissertation writing help #websites that write papers for you for free #write my essay for me cheap #pay someone to write my paper #pay someone to write my research paper #Essaywriting #Academicwriting #Assignmenthelp #Nursingassignment #Nursinghomework #Psychologyassignment #Physicsassignment #Philosophyassignment #Religionassignment #History #Writing #writingtips #Students #universityassignment #onlinewriting #savvyessaywriters #onlineprowriters #assignmentcollection #excelsiorwriters #writinghub #study #exclusivewritings #myassignmentgeek #expertwriters #art #transcription #grammer #college #highschool #StudentsHelpingStudents #studentshirt #StudentShoe #StudentShoes #studentshoponline #studentshopping #studentshouse #StudentShoutout #studentshowcase2017 #StudentsHub #studentsieuczy #StudentsIn #studentsinberlin #studentsinbusiness #StudentsInDubai #studentsininternational