1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
swat32
3 years ago
12

Create a simple main() that solves the subset sum problem for any vector of ints. Here is an example of the set-up and output. Y

ou would fill in the actual code that makes it happen. int main() { int TARGET
Computers and Technology
1 answer:
OverLord2011 [107]3 years ago
6 0

Answer:

Let isSubSetSum(int set[], int n, int sum) be the function to find whether there is a subset of set[] with sum equal to sum. n is the number of elements in set[].

The isSubsetSum problem can be divided into two subproblems

…a) Include the last element, recur for n = n-1, sum = sum – set[n-1]

…b) Exclude the last element, recur for n = n-1.

If any of the above the above subproblems return true, then return true.

Explanation:

Using C++

// A recursive solution for subset sum problem

#include <stdio.h>

// Returns true if there is a subset of set[] with sun equal to given sum

bool isSubsetSum(int set[], int n, int sum)

{

// Base Cases

if (sum == 0)

return true;

if (n == 0 && sum != 0)

return false;

// If last element is greater than sum, then ignore it

if (set[n-1] > sum)

return isSubsetSum(set, n-1, sum);

/* else, check if sum can be obtained by any of the following

(a) including the last element

(b) excluding the last element */

return isSubsetSum(set, n-1, sum) ||

isSubsetSum(set, n-1, sum-set[n-1]);

}

// Driver program to test above function

int main()

{

int set[] = {3, 34, 4, 12, 5, 2};

int sum = 9;

int n = sizeof(set)/sizeof(set[0]);

if (isSubsetSum(set, n, sum) == true)

printf("Found a subset with given sum");

else

printf("No subset with given sum");

return 0;

}

Output:

Found a subset with given sum

You might be interested in
Type the correct answer in the box Spell the word correctly.
Vinvika [58]

Answer:

Group

Explanation:

The strongest form of proximity effect is achieved through the overlapping of the objects. However, the Grouping of the objects also provides a similar sort of proximity strength, and hence here group is the right answer. Through, grouping the required level of the proximity effect is being provided to the objects, and this is one part of the Gestalt principle of design. You should know that Gestalt principles can easily elevate a design, and that is why they are so popular in design.

8 0
3 years ago
LITERALLY PLS ANYONE!!! 90 pointsss!
Doss [256]

7. Intentional Virus Setting is when you the user purposely spread computer viruses in order to do harm. It should be noted that this is highly illegal (no duh) with a sentence of up to 10 years and $250,000 in penalties assuming you are convicted under the Computer Fraud and Abuse Act of 1986 here in the States.

8. intrusion of solitude, appropriation of name or likeness, public disclosure of private facts, and false light.

9.  Intentionally creating and/or sending a virus and infecting people's computers is against the law, and can result in jail time or a fine.

10. Some examples are: Deception - Lying about how information will be used. Violation of confidentiality - Disclosing someone's personal information without consent. Intrusion - Interference in an employee's personal life. Misappropriation - Using a person's likeness to promote a product without his consent.

11. Everyone wants PRIVACY for themselves, and everyone wants ACCOUNTABILITY from others. Privacy is a basic human need, and invasion of privacy can have serious psychological and emotional consequences, including paranoia, anxiety, depression and broken trust. Invasion of privacy is both a legal and an ethical issue.

12. A cause of action for invasion of privacy entitles the plaintiff to recover damages for the harm to the particular element of his or her privacy that is invaded. Thus, one who suffers an intrusion upon his or her solitude or seclusion, may recover damages for the deprivation of his or her seclusion.

13. An acceptable use policy (AUP) is a document stipulating constraints and practices that a user must agree to for access to a corporate network or the Internet. Many businesses and educational facilities require that employees or students sign an acceptable use policy before being granted a network ID.

14. Intellectual property refers to creations of the mind: inventions; literary and artistic works; and symbols, names and images used in commerce. Intellectual property is divided into two categories: Industrial Property includes patents for inventions, trademarks, industrial designs and geographical indications.

PLEASE PLEASE PLEASE HELP WITH MY RECENT!!!!!!

btw hope this helps if it does please make brainliest :)

6 0
3 years ago
Read 2 more answers
To add a glow effect to WordArt text, which of the following should be done?
g100num [7]
Number 2 is the correct answer
8 0
3 years ago
When making a While Loop in Python, what button should I press?
olganol [36]
D. None of the above
8 0
4 years ago
One way to save time and get to the colleges that you are most interested in at a college fair is to
son4ous [18]

Answer:

Identify the location of the college stand in advance.

Explanation:

One way to save time and get to the colleges that you are most interested in at a college fair is to find out in advance the information about the fair, the colleges that are participating and from that pick the more interesting ones and identify the location of their stands. Like that when you arrive to the fair you can go directly to them and find them easily which will save you a lot of time as you won't be walking around the whole place to find them.

8 0
3 years ago
Read 2 more answers
Other questions:
  • If a user on a laptop complains that they are unable to sign into windows even though they are certain they are entering the cor
    6·1 answer
  • How it print media used? ​
    9·1 answer
  • Suppose a computer has 16-bit instructions. The instruction set consists of 32 different operations. All instructions have an op
    7·1 answer
  • An administrator needs to make sure that video conferencing is allocated a high portion of bandwidth within a company network. W
    11·1 answer
  • Briefly describe the interface between the memory and the processing unit. That is, describe the method by which the memory and
    6·1 answer
  • If you hear that an airplane crashes into the Empire State Building, and you immediately think of the 9/11 terrorist attack on t
    9·1 answer
  • can you give me a tip to fix my SIM card becuaus when i put it on my phone it has no signal , can anyone fix this , thank you.​
    9·2 answers
  • Which is the best defense against ESD?
    9·2 answers
  • A data table is a range that displays what?
    15·2 answers
  • What is the most used gaming keyboard in 2022?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!