Subset Sum theory and solutions [closed] - computation-theory

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
Subset problem is defined in Wikipedia as follows:
Given a set of integers, is there a non-empty
subset whose sum is zero? For example, given the set { −7, −3, −2, 5,
8}, the answer is yes because the subset { −3, −2, 5} sums to zero.
or
given a set of integers and an integer s, does any non-empty subset sum to s?
Brute force solution for this problem is exponential (cycle through all subsets of N numbers and, for every one of them, check if the subset sums to the right number), there some optimized version for brute force running in exponential time as well.
Let suppose there is an algorithm that can compute a brute force solution (exact solution to above questions) in between quadratic and polynomial time complexity
How it would be considered related to P=NP question, time complexity and so on?
Supposing algorithm exists, would be an improvement to state of the art for the subset sum problem?
(I'm not an expert on this area so if something does not make sense or is not clear I'll provide additional input to this question to the extent I'm able to :) )

Since the subset problem is NP-complete, if you can find a polynomial time solution to the problem, then you can solve all problems in NP in polynomial time, and P = NP.
Now, of course the above statement wouldn't make sense without understanding what NP and NP-completeness are. There are many ways to define NP problems, but the simplest way is that a problem is in NP if and only if there exists a verifier that can check the correctness of its solution in polynomial time. In the case of the subset sum problem, clearly you can verify its solution in polynomial time. Therefore, it's an NP problem.
The class NP-complete is a special set of problems in NP such that all problems in NP can be reduced to any problem in NP-complete in polynomial time. As an example, the first proven NP-complete problem by Cook is the SAT problem, where you try to decide if there exists a possible assignment to a set of boolean variables such that a boolean formula would evaluate to true. With the correct procedure, you can transform all decision problems in NP to SAT in polynomial time, and this makes SAT NP-complete. You can find more details about the original proof here, but it requires some understanding of the Turing machine.
To prove the NP-completeness of a new problem, you can try to reduce an existing NP-complete problem to the new one. As an example, we know that the SAT problem can be easily reduced to a 3-SAT problem. This means given a SAT problem, we can transform it into a 3-SAT version such that solving the equivalent 3-SAT problem would give us the result of the original SAT problem. Since all problems in NP can be reduced to SAT, and SAT can be reduced to 3-SAT, this makes the 3-SAT problem NP-complete.
Here is a nice proof of how you can reduce 3-SAT to the subset sum problem. As a consequence of the proof, the subset sum problem is NP-complete. Hence, if you can find a polynomial time solution to the subset sum problem, you can then solve all NP problems (yes, including problems such as the traveling salesman, graph coloring, knapsack, etc.) in polynomial time (since all reductions are done in polynomial time).

Related

Classification and complexity of generating all possible combinations: P, NP, NP-Complete or NP-Hard

The algorithm needs to generate all possible combinations from a given list (empty set excluded).
list => [1, 2, 3]
combinations => [{1}, {2}, {3}, {1,2}, {1,3}, {2,3}, {1,2,3}]
This algorithm would take O(2n) time complexity to generate all combinations. However, I'm not sure if an improved algorithm can bring this time complexity down. If an improved algorithm exists, please do share your knowledge!
In the case that it takes O(2n) which is exponential, I would like some insight regarding which class this algorithm belongs to P, NP, NP-Complete, or NP-Hard. Thanks in advance :)
P, NP, NP-complete, and NP-hard are all classes of decision problems, none of which contain problems that involve non-binary output (such as this enumeration problem).
Often people refer colloquially to problems in FNP as being in NP. This problem is not in FNP either because the length of the output string for the relation must be bounded by some polynomial function of the input length. It might be FNP-hard, but we're getting into the weeds that even a graduate CS education doesn't cover. Worth asking on the CS Stack Exchange if you care enough.
This problem is in none of them except, arguably, NP-hard.
It is not in P because there is no polynomial time algorithm to do it. You cannot generate an exponential number of things in polynomial time.
It is not in NP because there is no polynomial time algorithm to validate the answer. You cannot process an exponential number of things in polynomial time.
It is not in NP-complete because everything in NP-complete must be in NP and it is not.
The argument for it being in NP-hard goes like this. You can say anything that you want about the members of the empty set. Including that they make monkeys fly out of your nose and can solve any problem in NP in polynomial time. So if we could find a polynomial solution, we can solve any NP problem fast, and therefore it meets the definition of NP-hard. But uselessly so - we know that no polynomial solution exists.

Some inference about NP [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 7 years ago.
Improve this question
this is my first question on this site.
I‌ recently, study on NP. I have some confusion about this Topic, and want to propose my inference and some one verify me.
I) each NP problem can be solved in Exponential Time.
II) if P=NP then NP=NP-Complete.
III) Problem of factorization into 2-prime factor, is NP.
IV) if problem X can reduce to a known NP-Hard problem, then X must be
NP-HARD.
anyone can verify my inference and learn me?‌
I) each NP problem can be solved in Exponential Time.
Yes, this because it can be solved in polynomial time on Non Determinisitc Machine (definition of NP), and thus can be solved on a Deterministic Machine in exponential time.
II) if P=NP then NP=NP-Complete.
Yes, because if P=NP, "yes" and "no" answers for all NP problems are equivalently easy to achieve, run the polynomial time algorithm for the "yes" problem, and answer like it. Result is always correct and runs in polynomial time, assuming such a polynomial time machine exists.
III) Problem of factorization into 2-prime factor, is NP.
Yes. Given an number and its prime factorization - it is easy to verify if this is the correct answer (this is equivalent definition of problem being in NP).
IV) if problem X can reduce to a known NP-Hard problem, then X must be
NP-HARD.
No, it should be the other way around. You need to reduce a known NP-Hard Problem to X, and then you can tag X as NP-Hard.
Rememeber that every problem in NP has a reduction to SAT (Cook Levin theorem), and yet P != NP-Complete (or so we think at least)

If P=NP then how we can we say P=NP=NP-complete? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
In wikipedia I found this diagram. I don't get how under the asumption p=np we get p=np=np-complete?
Not sure this is on topic for stack overflow (Theoretical Comp Sci), but NP-hard, as correctly visualized in the diagram is "the set of problems that are at least as hard as those in NP"; this includes problems that are worse than NP in one sense or another.
NP-complete problems are those problems in NP-hard that have a reducibility relationship with specific problems that are known to be in NP. Essentially, every problem that can be converted in polynomial time or better to a problem in NP-complete is just as hard as the others.
Here are a couple good snippets from CLRS that illustrate the issue:
The class NP consists of those problems that are “verifiable” in polynomial time. What do we mean by a problem being verifiable? If we were somehow given a "certificate” of a solution, then we could verify that the certificate is correct in time polynomial in the size of the input to the problem.
Informally, a problem is in the class NPC—and we refer to it as being NP-complete—if it is in NP and is as “hard” as any problem in NP.
A decidable language L is NP-complete if:
L is in NP, and
L' can be reduced to L in polynomial time for every L' in NP.
If a language L satisfies property 2, but not necessarily property 1, we say that L is NP-hard. We also define NPC to be the class of NP-complete languages.
(I may have the L' and L backwards there, the reducibility symbol is backwards from the way it is read in English.)
So what's the point? Well, you can just solve it with set theory: NP-complete is a subset of NP, and if P=NP, then NP-complete is a subset of P (in fact, they all become equal at that point, since you can solve any of them by first changing them to something your magic P-algorithm can work on). NP-hard still includes some NP-complete problems, but there are other problems outside, which are just hard.

Can 1 approximation algorithm be used for multiple NP-Hard problems?

Since any NP Hard problem be reduced to any other NP Hard problem by mapping, my question is 1 step forward;
for example every step of that algo : could that also be mapped to the other NP hard?
Thanks in advance
From http://en.wikipedia.org/wiki/Approximation_algorithm we see that
NP-hard problems vary greatly in their approximability; some, such as the bin packing problem, can be approximated within any factor greater than 1 (such a family of approximation algorithms is often called a polynomial time approximation scheme or PTAS). Others are impossible to approximate within any constant, or even polynomial factor unless P = NP, such as the maximum clique problem.
(end quote)
It follows from this that a good approximation in one NP-complete problem is not necessarily a good approximation in another NP-complete problem. In that fortunate world we could use easily-approximated NP-complete problems to find good approximate algorithms for all other NP-complete problems, which is not the case here, as there are hard-to-approximate NP-complete problems.
When proving a problem is NP-Hard, we usually consider the decision version of the problem, whose output is either yes or no. However, when considering approximation algorithms, we consider the optimization version of the problem.
If you use one problem's approximation algorithm to solve another problem by using the reduction in the proof of NP-Hard, the approximation ratio may change. For example, if you have a 2-approximation algorithm for problem A and you use it to solve problem B, then you may get a O(n)-approximation algorithm for problem B, since the reduction does not preserve approximation ratio. Hence, if you want to use an approximation algorithm for one problem to solve another problem, you need to ensure that the reduction will not change approximation ratio too much in order to get a useful algorithm. For example, you can use L-reduction or PTAS reduction.

NP-Hard solution question

i have NP hard problem. Let imagine I have found some polynomial algorithm that find ONLY one of many existing solutions of that problem, but at least one solution (if present in the probem). Is that algorithm considered as solution of NP=P question (if that algorithm transformed to mathematical proof)?
Thanks for answers
NP is a class of decision problems. Your algorithm should answer "yes" or "no" correctly to all possible instances (questions).
For example, the problem: "given graph G and number k, does G contain a clique of size >= k" is NP-hard. If you have a polynomial time algorithm that answers "yes" or "no" correctly each time, then it is a valid proof of P=NP. The algorithm doesn't need to explicitly show the clique - only answer if it exists for all possible G and k.
If you find a NP-hard problem and you can detect some cases that you can solve in polynomial time (leaving others for exponential time), then only if the fraction of cases remaining is on the order of log(N)/N will you change the order of the entire problem, and even then only if you can restrict your exponential case to examining only log(N) not all N possibilities.
Also, if you find a NP-hard problem where you think you can solve every case in polynomial time, you have probably made a mistake, either in posing a NP-hard problem correctly, or in finding the more troublesome examples. Try a larger test set before believing yourself!

Resources