Find a subset of b whose elements summation is equal to k

Assignment Help Software Engineering
Reference no: EM13330113

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

Input: set B of n positive integers {b1, b2,....., bn} and 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 2n (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.

2. 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 B of n 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.

Reference no: EM13330113

Questions Cloud

Create all the possible combinations of array a : The subset-sum problem is defined as follows: given a set B of n positive integers and an integer K, can you find a subset of B whose elements' summation is equal to K? Design an algorithm to solve this problem. Address its correctness and running..
Determine the position of the object : A converging lens with a focal length of 11.4cmforms a virtual image 7.55mm tall, 16.6cm to the right of the lens. Determine the position of the object
Depict the ph curve for the titration solution of weak base : After completing the calculations below, sketch the pH curve for the titration of 25.0 mL of 0.150 M solution of a weak base, B (Kb = 6.8 x 10^-5), with 0.150 M HI. Indicate the pH
Obtain the magnitude of the average force : A rare isotope facility produces a beam of 7.11E5 nuclei per second of a rare isotope with mass 6.43E26 kg.  What is the magnitude of the average force that this beam exerts on the beam stop
Find a subset of b whose elements summation is equal to k : The subset-sum problem is defined as follows: given a set B of n positive integers and an integer K, can you find a subset of B whose elements' summation is equal to K? Design an algorithm to solve this problem. Address its correctness and running..
Find the time it takes for the object to strike the ground : An object has a mass of 0.500kg is released from the top of a building of height 7.00m. Find the time it takes for the object to strike the ground
What impulse was applied to the ball during the collision : A rubber ball of mass 39.0 g is dropped from a height of 1.80 m onto a floor. The velocity of the ball is reversed by the collision with the floor, What impulse was applied to the ball during the collision
Find the magnitude of the force between the two blocks : Two blocks are in contact on a frictionless table. A horizontal force F is applied to m1. If m1 = 1.66 kg, m2 = 3.72 kg, and F = 6.25 N, find the magnitude of the force between the two blocks
Estimate the induced dipole moment of an oxygen atom : The polarizability of large atoms can be estimated by using the formula for the polarizability of a metal sphere, \(\alpha = 4\pi\epsilon a^{3}\), Estimate the induced dipole moment of an oxygen atom

Reviews

Write a Review

Software Engineering Questions & Answers

  Importance of professional looking worksheets

Discuss and explain in Excel why is it important to have a professional looking worksheet? Why spend so much time with styles and formats and creating borders?

  Office automation project in the printing industry

Discuss possible ramifications of these opposing objectives on the project and Which strategy do you favour? Justify your answer with relevant theory.

  Write down critical success factors for project manager

Write down the critical success factors for project manager? what skills must managers look for when hiring someone who would be successful in this job?

  Sketch the e-r diagram for university

Sketch the E-R diagram for each of the following situations (if you believe which you need to make extra assumptions, clearly define them for each situation).

  What would you consider some of the key considerations

Explain your choices. Is the organization you work for (or one that you are familiar with) meeting these key considerations?

  Describe purpose of the keyword super in programs

Describe purpose of the keyword super in programs

  Design user-s requirements specification for school

Design a user's requirements specification for the EasyDrive School of Motoring database system. Use a single major user view for the application (Director View)

  Evaluate the importance of being an agile coach

Compare at least three (3) different facilitation techniques among agile coaches and provide examples of each to justify how the techniques help solve problems and improve management.

  Architecture tradeoff analysis method

what is the methods for according to specific quality attribute like (performance, reliability  ...etc.)?Is it possible to use  Architecture Tradeoff Analysis Method  ( ATAM )  for optimization ?

  Effects about workplace automation

A multinational company transfers a foreign employee to the U.S. on an L-1 visa. The foreign worker is a computer programmer, working alongside an American computer programmer doing the same work.

  Describe your chosen architecture pattern

Include charts or diagrams created in Visio or an equivalent such as Dia. The completed diagrams / charts must be imported into the Word document before the paper is submitted.

  Define the terms variable and constant

Discuss and define the terms "variable" and "constant" as used in computer programming. Estimate the many types of data that can be used in developing a solution.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd