Create all the possible combinations of array a

Assignment Help Software Engineering
Reference no: EM13330117

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.

 

Reference no: EM13330117

Questions Cloud

What happens to the center of mass of two-particle system : Two particles lie on an x axis, particle 1 at x = 1 m and particle 2 at x = 2 m. what happens to the center of mass of the two-particle system
Find the magnitude and direction of the magnetic force : A horizontal conductor in a power line carries a current of 5500 A from south to north. Find the magnitude and direction of the magnetic force
How fast can it lift the crate : An electric motor is rated to have a maximum power output of 0.68 hp. how fast (i.e., at what speed) can it lift the crate
Explain the molar solubility of the metal hydroxide : A) A saturated solution of metal hydroxide, M(OH)2, has a pH of 10.05. Calculate the molar solubility and the Ksp for this metal hydroxide. M(OH)2 (s) M2+ + 2OH- (aq) B) What is the molar solubility of this metal hydroxide in 0.10 M M(NO3)2
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..

Reviews

Write a Review

Software Engineering Questions & Answers

  Question about inheritance

In computer programming would you say that a function could also be called an inheritance item due to the reuse of it in the program?

  Many midsized firms are investing in erp system packages

Many midsized firms are investing in ERP system packages, such as SAP and PeopleSoft.Comment on what you think might be particularly important parts of the decision-making process when the purchasing organization has only a small IS department.

  How could core erp components aid improve business operation

How could core ERP components aid improve business operations at college? How could extended ERP components aid improve business operations at the college.

  Use e-r approach to model operations of local library

Use the E-R approach to model the operations of your local community library. The library has books, CDs, tapes, and so forth, which are lent to library patrons.

  Draw an e-r diagram for hospital staff

Draw an E-R diagram for the following situations. From discussions with hospital staff, reviewing hospital documents and studying existing information systems, the study team developed a list of business rules.

  Challenges of software development projects

Define and explain, in your own words, the primary challenge(s) of software development projects and compare and contrast at least three (3) different software development methods.

  Describe the issues central to ensuring quality of software

Minimum number of words 500, referencing with Harvard style and the number of references not less than three Academic Articles or books.

  Development of a small software system

Analysis, design and development of a small software system.

  Define a class called counter

Define a class called Counter. An object of this class is used to count things so it records a count that is a non-negative whole number. Include methods to set the counter to 0, to increase the counter by 1, and to decrease the counter by 1.

  Study guide - ip address

Discuss when a person types in a domain name such as IBN . COM, how is this recognized by the computer as an IP address and explain ow are IP addresses used?

  Describing rfid systems used in inventory control

Illustrate how are RFID systems used in inventory control and supply chain management? What kinds of relationships are possible in relational database?

  Question about hippa rights

I have found that to date, the largest offense is looking into family records even though workers are warned not too and that this is a violation of that family member's HIPAA's rights.

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