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

  Draw entity relationship model for project management system

A consultant is not necessarily a project leader, but they can only be project leader for one project. Draw an entity relationship model for the project management System.

  Draw e-r diagram which models online bookstore

Draw the E-R diagram which models an online bookstore. List entity sets and their primary keys. Assume the bookstore adds music cassettes and compact disks to its collection.

  Question about programming languages

Various contemporary languages permit two kinds of comments, one in which delimiters are used on both ends, and one in which delimiter marks only the starting of the comment, Discuss the advantages and disadvantages of each.

  How project leader finds what user wants and needs

How can project leader find what user wants and needs. Point about observing the user is important step in gaining good understanding of the users needs.

  What is the pattern in the optimal allocation

What are the optimal production quantities for the company? What is the pattern in the optimal allocation?

  Suggestions for viable guidelines

Do you think that variations in company and societal culture could pose a significant problem when coordinating or scheduling large assignments,

  Draw a state chart that models the operation

Draw a state chart that models the operation of the tape recorder and When the end of tape is reached, the machine will automatically continue playing in the reverse direction, i.e. play the other side of the tape.

  Explain the importance of software testing

Evaluate the issues and challenges associated with software engineering.  Compare and contrast software development process models.

  Identify resource requirements

The purpose of the BIA is to identify and prioritize system components by correlating them to the business process(es) the system supports, and by using this information to characterize the impact on the process(es) if the system were unavailable.

  Preparing final table list and rationale

Assume you are now going to construct the final table list for Fernando's Skate Shop. Use the following preliminary field list and list of subjects to get started.

  Draw fully annotated e-r diagram showing entities

Find the case requirements and analyze them. A fully annotated E-R diagram 1 and 2 showing the entities, primary and foreign keys, composite keys and relationships.

  What are the ramifications of the parts

Consider the type of software process used in your organization (or one in which you have previously worked). How many of the key process areas identified in the course are used?

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