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

  Process of requirements elicitation and validation

Give reasons why the process of requirements elicitation and validation is an iterative one and what roles does the requirement documentation play in the process of requirements elicitation and validation?

  Finding error in code sequence

This code prints all elements of the array geo for, Describe what the problems are and how to fix them.

  Importance of framing a problem

A program that tells a bus rider which buses to take to get from one location to another, arriving by a specified time.

  Decimal octal hex binary value

Decimal Octal Hex Binary Value The table depicts device control codes from the ____character coding standard.

  Sketch er diagram to keep track of employees and projects

Sketch ER diagram for the following situation and write any assumptions you think you have to make to develop a complete diagram. Company requires the operational database to keep track of all employees, departments, and projects.

  Importance of various system analysis

In this class, we've stressed the importance of various system analysis and design tools and techniques. By now you should have a "toolbox" full of useful design and analysis tools.

  Develop a persistence mechanism using data access objects

Map the information required by the relevant domain object classes onto a set of relational database tables in third normal form. Specify the table design.

  Jrp a superior way to discover requirements

What makes JRP a superior way to discover requirements as compared to a regular company meeting? What do you think is the most important aspect of a JRP meeting

  Explain alternative programming languages available

Describe a design of your chosen system and explain the basic architechture of a knowledgebased system.

  Calculate the sum of the positive elements of each row

Call a procedure to display the array as a table and redisplay the menu after each task is completed and reported.

  Develop an activity diagram for the use case

Develop an Activity Diagram for the use case chosen in part A and develop a System Sequence Diagram (SSD) for the complete overall system and a Sequence Diagram (SD) for your selected use case.

  Different approaches for system development

In Systems Analysis and Design. There are at least 2 approaches to system development, variety of life cycles, and long list of techniques.

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