Soit et sous-ensembles de . Nous souhaitons trouver la somme de Minkowski .
is a characteristic function of if
Let be the discrete convolution of and , then if and only if . Hence can be computed in time by discrete convolution via FFT.
Sometimes it is important to find out the actual pair and that sums to . is called a witness of , if there exist such that . A function is called a witness function if is a witness of .
Is it possible to compute a witness function in time?
convolution
fft
Chao Xu
la source
la source
Réponses:
Here I am explaining how to getO(n∗polylogn) randomized running time. We need a sequence of observations:
A witness of a valuev is a pair of numbers (a,b)∈A×B such that a+b=v . Let PA(x)=∑i∈Axi and PB(x) be defined analogously. Observe that the coefficient of xv in PA(x)∗PB(x) is the number of witnesses there are for the value v .
Assumev has a single witness (a,b)∈A×B , and consider the the polynomial QA(x)=∑i∈Ai∗xi . Clearly, the coefficient of xv in QA(x)∗PB(x) is a , and as such we now know the pair (a,v−a) and we are done.
So, we are done with the case that there is a single witness. So consider the case thatv has k witnesses (a1,b1),…,(ak,bk) . Let i(k)=⌈lgk−−√⌉ . Observe that 2i(k)−1≤k−−√≤2i(k) .
Next, let Rj=(Aj,Bj) , for j=1,…,m , for m=O(logn) be random samples, such that each element of A is choosen into Ai with probability p=1/2i(k) . The probability that v has a single witness in Rj is α=(k1)p2(1−p2)k−1 , since the witness are disjoint pairs of numbers (since the sum of each pair is v ). It is easy to verify that α is a constant in (0,1) independent of the value of k . As such, it must be, with high probability, that v has a single witness in one of the samples R1,…,Rm . As such, by computing the two polynomials associated with with such sample, as described above, in O(nlogn) time (per sample), using FFT, we can decide this in constant time.
We are almost done. Compute the above random samples for resolutionsi=1,…,⌈lgn⌉ . For each such resolution compute the random samples and associated polynomials. Also, compute the associated polynomial for A and B . This preprocessing naively takes O(nlog3n) , but I suspect that being slightly more careful a logn factor should be removable.
The algorithm: For every valuev , compute how many witness, say k, it has in constant time, by consulting the polynomial QA(x)∗PB(x) . Next, go to the relevant data-structure for i(k) . Then, it finds the random sample that has it as a single witness, and it extract the pair that is this witness in constant time.
Strangely enough, the preprocessing time isO(nlog3n) , but the expected time to find the witness themselves take only O(n) time, since one can stop the search as soon as one find a witness. This suggests that this algorithm should be improveable. In particular, for i(k)≪lgn , the polynomials generated are very sparse, and one should be able to do much faster FFT.
la source
Ok, I've been holding off since really Sariel should get credit for an answer, but I'm tired of waiting, so here is my cut at a near-linear randomized algorithm.
This blows up the running time by three logarithmic factors; probably that can be reduced.
la source
This answer gives a determinsticO(n polylogn) algorithm.
It appears that Sariel and David's algorithm can be derandomized through an approach similar to this paper. [2] While going through the process I found there is a more general problem that implies this result.
Letf be the running time of calling the oracles, and assume f=Ω(m+n) , then one can find the sets in deterministic O(fklogn polylog(m)) time. [1]
Now we can reduce the finding witness problem to1 -reconstruction problem. Here S1,…,S2n⊂{1,…,2n} where Si={a|a+b=i,a∈A,b∈B} .
Define the polynomialsχQ(x)=∑i∈Qxi , IQ(x)=∑i∈Qixi
The coefficient forxi in χQχB(x) is |Si∩Q| and in IQχB(x) is ∑s∈Si∩Qs . Hence the oracles take O(nlogn) time per call.
This gives us anO(n polylog(n)) time deterministic algorithm.
[1] Yonatan Aumann, Moshe Lewenstein, Noa Lewenstein, Dekel Tsur: Finding witnesses by peeling. ACM Transactions on Algorithms 7(2): 24 (2011)
[2] Noga Alon, Moni Naor: Derandomization, witnesses for Boolean matrix multiplication and construction of perfect hash functions. Algorithmica 16(4-5) (1996)
la source