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

  Explain clark-wilson model is implemented on computer system

Assume that the Clark-Wilson model is implemented on a computer system. Could a computer virus that scrambled constrained data items be introduced into the system?

  Fixing errors for java code

The code compiles properly and runs, but result is not what you expected; output is similar to the following, Describe what the problem is how to fix it.

  Qiestion about update statement

A table namedPoints varchar(81) has values stored in a column named Point. There are 2-columns in the Points table, X and Y.

  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 ?

  Draw flowchart-write pseudocode to represent logic

Draw a flowchart or write pseudocode to represent the logic of a program that allows the user to enter three values.

  Design the requires and the provides interfaces

Design the Requires and the Provides interfaces of at least two (2) components that might be used in a system in an emergency control room for a call-logging component that records calls made.

  Explain commercial applications development

Eight clubs compete in a tenpin bowling competition. There are ten frames (sets of pins) and two balls are available if required by each competitor in each frame to knock down all pins. A "strike" is when all pins are knocked down with the first b..

  Create an algorithm using pseudo code

Create an algorithm, with the help of pseudo code, to perform one of the following tasks, string of numbers, identify all of the substrings that form numbers that are divisible by 3.

  Classification of symbols

In few programming languages a comment can be enclosed either in braces {} or in the symbols (* *). Discuss how do you think a scanner would group the four symbols {, }, (*, *) for purposes of classification.

  Risk management in tellers in four-digit numeric password

Tellers at each branch use a four-digit numeric password, and each teller's computer is transaction-coded to accept only its authorized transactions. Carry out a risk assessment.

  Defining competitive advantage of a business

Discuss the key concepts related to defining competitive advantage of a business? Choose one and describe how you would use information systems to aid in obtaining competitive advantage with your selected key idea.

  Study the following filenames which contain wildcards

Give three examples of filenames that would match each of the following wildcard patterns.

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