26 Jun The subset-sum problem is defined as follows:
Question
9) Thesubset-sumproblem is defined as follows: given a setBofnpositive integers and an integerK,can you find a subset ofBwhose elements’ summation is equal toK?Design an algorithm to solve this problem. Address its correctness and running time.
Input: setBofnpositive integers {b1, b2,….., bn}and an integerK.
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 2n (We have 2n different combinations set to be checked)
1. Create all the possible combinations of Array A and do:
§ Compute Sum =.png”>
§ 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 canpartitiona set of positive integers into two equal weight subsets. How could you use this procedure to solve thesubset-sumproblem?
To solve this we use reduction. In which prove thatsubset-sumproblem can be reduce topartition problem and visa versa.
The setBofnpositive integers whose element summation is equal to an integerK.
Partition reduces to Subset Sum:
Calculate Sum =.png”>, which is the summation of all the given numbers. A partition.png”> Subset Sum if K = Sum/2.
Subset Sum reduces to Partition:
Calculate Sum =.png”>, 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}.png”> {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.
Thesereference 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.
Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.
About Writedemy
We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.
How It Works
To make an Order you only need to click on “Order Now” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Are there Discounts?
All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.
