[algogeeks] Array Reconstruction

2010-07-09 Thread amit
Given a list of numbers, A = {a0, a1, ..., an-1}, its pairwise sums P are defined to be all numbers of the form ai + aj for 0 = i j n. For example, if A = {1,2,3,4}, then P = {1+2, 1+3, 1+4, 2+3, 2+4, 3+4} = {3, 4, 5, 5, 6, 7}. Now give you P, design an algorithm to find all possible A. -- You

Re: [algogeeks] Array Reconstruction

2010-07-09 Thread Ashish Goel
a minor correction nC2 possibilities so n can be found using nC2=say6 then n=4 a+b=p0 a+c=p1 a+d=p2 b+c=p3 b+d=p4 c+d=p5 3a+b+c+d=po+p1+p2 b+c+d=(p3+p4+p5)/2 so a= (2(p0+p1+p2)-p3-p4-p5)/6 take case of 5 numbers {1,2,3,4,5} P={3,4,5,6,5,6,7,7,8,9} 5C2=10 so n=5

Re: [algogeeks] Array Reconstruction

2010-07-09 Thread Amit Jaspal
nice approach Ashishthkz On Fri, Jul 9, 2010 at 11:14 AM, Ashish Goel ashg...@gmail.com wrote: a minor correction nC2 possibilities so n can be found using nC2=say6 then n=4 a+b=p0 a+c=p1 a+d=p2 b+c=p3 b+d=p4 c+d=p5 3a+b+c+d=po+p1+p2 b+c+d=(p3+p4+p5)/2 so a=