7

Let $N \geq 4$ be an integer, and suppose we have two strictly increasing finite sequences of positive integers $(x_i)$ and $(y_j)$ (where $1 \leq i \leq N$ and $1 \leq j \leq N$) such that $x_1 = y_1 = 0$. Let's also define the sums $s_{i, j} = x_i + y_j$, for all integers $i$ and $j$ in the range $[1, N]$.

Now, if we are only given the (unordered and unlabeled) $N^2$ values of $(s_{i, j})$, is there a general, constructible way to find a valid pair of sequences $(x_i)$ and $(y_j)$ that would "generate" these $s_{i, j}$ sums ?

Ideally, I'd also like the algorithm to have a polynomial time complexity, but I don't know if such an algorithm exists. Thanks in advance !

bghost
  • 549
  • 2
  • 10
  • Are you guranteed that the numbers can be found from two such sequences? Or do you also want a decision procedure to return "Error" if no such sequences exist? – HackR Nov 08 '24 at 17:02
  • What did you try to solve this problem? – Smylic Nov 08 '24 at 18:53
  • @HackR Yes, if the $s_{i, j}$ are defined as $s_{i, j} = x_i + y_j$, then you'll always be able to find a solution, eventually. I'm just wondering if there exists an algorithm to solve this problem in a polynomial time complexity ! In this problem, we can assume that a solution will always exist, given the $s_{i, j}$. – bghost Nov 08 '24 at 21:40
  • @Smylic To be honest, I don't really know where to start to solve this problem. I initially tried to order the $s_{i, j}$ in ascending order, then make deductions based on that ordering, but I didn't manage to find a general way to extract the $x_i$ and $y_j$ from the $s_{i, j}$. Also, because we know that $x_1 = y_1 = 0$, the $(x_i)$ and $(y_j)$ are essentially "hiding in plain sight" within the $s_{i, j}$, as they correspond to the $s_{i, 1}$ and $s_{1, j}$ sums (respectively). I thought that the previous fact would make the problem much easier, but obviously I was wrong ! – bghost Nov 08 '24 at 21:48

2 Answers2

1

This isn't a complete algorithm, but rather an idea that hopefully someone else can build off of.

One potential way to frame the problem is that we seek two polynomials, $P(z)$ and $Q(z)$: $$ P(z) = \sum_{i=1}^{N} z^{x_{i}} \qquad Q(z) = \sum_{i=1}^{N} z^{y_{i}} $$ Such that their product corresponds to our sums: $$ R(z) = P(z) \cdot Q(z) = \sum_{i=1}^{N} \sum_{j=1}^{N} z^{s_{i,j}} $$ You could then factor $R(z)$, using a polynomial time factoring algorithm to obtain its irreducible factors over the integers. Then you'll need to combine these factors into two polynomials with $N$ non-zero terms each.

Note that $x_1 = y_1 = 0$, $s_{1,1} = 0$, meaning all factors will have a constant term, and that there will be no overall constant factor.

Also note that $P(1) = Q(1) = N$. This implies that for each of our polynomial factors $p_i(z)$, we have $p_i(1) \mid N$. This can allow us to efficiently mark factors as mutually exclusive (one belonging to each of $P(z)$ and $Q(z)$) if $p_i(1) \: p_j(1) \nmid N$. Polynomials can then be multiplied efficiently using the FFT, and terms checked. In many cases, there won't even be that many polynomial factors- almost all polynomials with coefficients zero or one are irreducible over the integers.

I'm struggling to bound this step in polynomial time, but maybe someone else can weigh in and prove a bound on the number of irreducible factors a polynomial with coefficients of ones and zeros can have.

One important caveat: the time complexity of this approach will be dependent on the values of your sequence, not just their length. For large $s_{i,j}$ this algorithm will perform terribly.

0

This answer is a hint, not a full solution. Suppose you arranged all $s_{i, j}$ in non-descending order. And you consider them one by one possibly discovering some of $(x_i)$ and $(y_j)$.

  1. What would you expect about relation between already discovered elements of $(x_i)$ and $(y_j)$ and still non-discovered ones?
  2. When you consider next $s_{i, j}$, can you understand whether it is sum of two already discovered elements or not? Firstly suppose that all $s_{i, j}$ are pairwise non-equal, and then think about possible equality.
  3. Can $s_{i, j}$ be sum of two non-discovered elements?
  4. If $s_{i, j}$ is sum of discovered and non-discovered elements can you say anything about $i$ or $j$?

After answering these questions think about polynomial solution, and then think about linear-logarithmic solution (that is $\mathrm{O}(N^2 \log N)$, because you have $N^2$ numbers in input).

Smylic
  • 8,098
  • Thanks for the hints, I'll try to answer them ASAP. Also, just to be 100% sure, are you implying that you have found a linear-logarithmic solution to solve this problem ? – bghost Nov 11 '24 at 18:35
  • @bghost I'm sorry, maybe I'm wrong. I can solve the same problem for all pairwise sums of $(x_i)$ in linear-logarithmic time. But for two sequences we have an extra uncertainty. And I need to think, how to handle it. Anyway answering my questions is useful to search for a solution – Smylic Nov 11 '24 at 19:25
  • Noted ! No worries – bghost Nov 11 '24 at 20:50