4

I am interested in the complexity of the following problem:

Input: A list $a_1\leq ⋯ \leq a_n$ of positive integers.

Question: Are there two vectors $x, x'\in\{−1,0,1\}^n$, with at least one $x_i$ and one $x'_i$ non-zero (the subsets must be non-empty), such that $$\sum_{i=1}^nx_ia_i=0, \sum_{i=1}^nx'_ia_i=0 \text{ and } x_ix'_i=0 \text{ }\forall i.$$ WEAK PARTITION is a variant of PARTITION where we are looking for a partition of a subset of the input, and not a partition of all the integers. This is the reason why we have $\{−1,0,1\}^n$ and not $\{−1,1\}^n$. Note that the subset must be non-empty, it means at least one $x_i$ must be non-zero.

But I am interested in the problem described above where we are looking for two distinct weak partitions. For example, with $A=(1,2,3,4,5,7,11,11)$, we have $x=(1,0,1,0,0,1,-1,0)$, $x'=(0,1,0,1,1,0,0,-1)$ and for each component $i$ we have $x_ix'_i=0$. It means we have two disjoint subsets of $A$ where there is a weak partition.

There is clearly a reduction from WEAK PARTITION but I suspect this problem to be NP-hard in the strong sense. Do you see any reduction from a problem which is NP-hard in the strong sense ?

Thank you very much.

Raphael
  • 73,212
  • 30
  • 182
  • 400

1 Answers1

4

No such reduction is likely to exist (unless P=NP). In particular, there's a pseudo-polynomial time algorithm for your problem, so your problem isn't strongly NP-hard (unless P=NP).

The algorithm uses dynamic programming and is a straightforward modification of the dynamic programming algorithm for PARTITION. Define $f(j,y,z)$ to be 1 if there exists two non-zero disjoint vectors $x,x'$ of the required form such that

$$\sum_{i=1}^j x_i a_i = y, \sum_{i=1}^j x'_i a_i = z.$$

Otherwise, $f(j,y,z)=0$. Also define $g(j,y)$ to be 1 if there exists a non-zero vector $x$ such that $\sum_{i=1}^j x_i a_i = y$, or 0 otherwise.

Note that $f,g$ satisfy the following recurrence relations:

$$\begin{align*} f(j,y,z) = &f(j-1,y,z) \lor f(j-1,y-a_j,z) \lor f(j-1,y+a_j,z) \lor f(j-1,y,z-a_j)\\ &\lor f(j-1,y,z+a_j) \lor (g(j-1,y) \land z=\pm a_j) \lor (g(j-1,z) \land y=\pm a_j).\\ g(j,y) = &g(j-1,y-a_j) \lor g(j-1,y+a_j) \lor g(j-1,y) \lor (y=\pm a_j).\end{align*}$$

The base cases are $f(0,y,z)=0$ and $g(0,y)=0$ for all $y,z$.

With this recurrence, evaluate $f(j,y,z)$ and $g(j,y)$ for all $0 \le j \le n$ and all $y,z$ satisfying $|y|,|z| \le a_1 + \dots + a_n$. Each such value can be computed in $O(1)$ time using memoization / dynamic programming.

Finally, look at the value of $f(n,0,0)$ that you computed. If $f(n,0,0)=1$, then there is a solution to your problem (i.e., there exists two disjoint vectors $x,x'$ that each represent two disjoint weak partitions).

What's the running time of the algorithm? If the inputs are represented in unary, the number of $f$-values we compute is polynomial in the size of the input, and each $f$-value can be computed in $O(1)$ time using the recurrence relation above. It follows that this dynamic programming algorithm runs in polynomial time, if the inputs are provided in unary.

D.W.
  • 167,959
  • 22
  • 232
  • 500