Create all the possible combinations of array a

Assignment Help Data Structure & Algorithms
Reference no: EM13309935

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.

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: EM13309935

Questions Cloud

Obtain the current in the inductor : An inductor has an inductance of 0.069 H. The voltage across this inductor is 56 V, What is the current in the inductor
What shape and distribution of mass should it have : To maximize the moment of inertia of a flywheel while minimizing its weight, what shape and distribution of mass should it have
Determine the ionization energy of hydrogen : Determine the ionization energy of hydrogen if the shortest wavelength in the Balmer series is found to be 3650 AO
A variable cross section data taken at two axial positions : An aqueous solution with a specific gravity of 1.12 flows through a channel with a variable cross section, data taken at two axial positions in the channel are shown here. Point 2 is 6.00 meters higher than point 1.
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..
How large an expansion tank do you specify : Fuel systems of modern cars are designed so thermal expansion of gasoline doesn't result in wasteful and polluting fuel spills. How large an expansion tank do you specify
Determine force exerted by the hydraulic cylinder on boom : A hoist mechanism is attached to the back of a pickup truck. The crate being moved by the hoist shown below weighs 200 lbs. Note: Point A is directly above point B and the vertical distance between points A and B is 16 inches.
Evaluate the equilibrium partial pressures of c2h6 : Calculate the equilibrium partial pressures of C2H6, N2, NH3, and C2H4. Peq(C2H6) = . Peq(N2) = . Peq(NH3) = . Peq(C2H4) = . (b) Calculate KP for this reaction. KP =.
At what distance from bottom of the hill did the car stop : on a windy day, a person on a cart (combined mass m of 70kg) begins at the top of a hill 10m hihg traveling at 3m/s, At what distance from the bottom of the hill did the car stop

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Implement an open hash table

In this programming assignment you will implement an open hash table and compare the performance of four hash functions using various prime table sizes.

  Use a search tree to find the solution

Explain how will use a search tree to find the solution.

  How to access virtualised applications through unicore

How to access virtualised applications through UNICORE

  Recursive tree algorithms

Write a recursive function to determine if a binary tree is a binary search tree.

  Determine the mean salary as well as the number of salaries

Determine the mean salary as well as the number of salaries.

  Currency conversion development

Currency Conversion Development

  Cloud computing assignment

WSDL service that receives a request for a stock market quote and returns the quote

  Design a gui and implement tic tac toe game in java

Design a GUI and implement Tic Tac Toe game in java

  Recursive implementation of euclids algorithm

Write a recursive implementation of Euclid's algorithm for finding the greatest common divisor (GCD) of two integers

  Data structures for a single algorithm

Data structures for a single algorithm

  Write the selection sort algorithm

Write the selection sort algorithm

  Design of sample and hold amplifiers for 100 msps by using n

The report is divided into four main parts. The introduction about sample, hold amplifier and design, bootstrap switch design followed by simulation results.

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