0

So I know the conditions required for a problem to be NP-Complete is that it has to lie within NP and has to be NP-hard.

The given problem I have is subset sum.

However, the conditions have been change to sum ≤ M and sum ≥ M from sum = M. To be more specific:

  1. "If we ask if there is a subset with sum ≤ M, is the problem still NP- Complete?"

  2. "If we ask if there is a subset with sum ≥ M, is the problem still NP- Complete?"

My initial reaction is that the two problems are no longer NP-complete since they can both be solved within polynomial time.

  1. Check each element and see if there exists at least one smaller than M.
  2. Add all positive integers and see if the sum of all elements is larger than M.

Since it isn't NP Hard, it cannot therefore be NP-complete.

Am I thinking/approaching this correctly?

red31
  • 155
  • 6

1 Answers1

2

What precisely are the problems? I may be missing something (and cannot do comments yet). Are they

(1) Given a set $A \subseteq \mathbb{Z}$ of $n$ elements, does there exist some subset $S \subseteq A$ with $\sum_{x \in S} x \le M$.

(2) Given a set $ \subseteq \mathbb{Z}$ of $n$ elements, does there exist some subset $S \subseteq A$ with $\sum_{x \in S} x \ge M$.

If so these problems seem clearly in $\mathbf{P}$, basically by the reasoning you described -- we just want the minimum/maximum possible subset sum, and then we compare that with $M$. Assuming empty $S$ is allowed:

  • for (1), add up all the negative numbers in $A$ and see if it's $\le M$. If Yes, then return yes. If not, return No.

  • for (2), add up all the positive numbers in $A$ and see if it's $\ge M$.

Again I may be missing something, but it seems like the other answer's reduction might not be addressing the possibility that $SS_\le$ and $SS_\ge$ would return yes based on different sets? Like consider input $A = \{1, 3\}$ and $M=2$.

xmq
  • 171
  • 2