Count the number of pair of points from a set of points whose mid points also lie in the same set.

57 Views Asked by At

So we have been given a set of points. We have to find the total number of points A and B selected from this set such that mid point of these 2 points also lie in the same set?

Let me give an example.

Suppose the given set is {(0,0), (0,1), (0,2), (1,0), (1,1),(1,2)}. Now we can have 10 points drawn from these sets such 
that there mid point also lies in the same set. Those ten points are
A=(0,0) B=(0,0) mp = (0,0)
A=(0,0) B=(0,2) mp = (0,1)
A=(0,1) B=(0,1) mp = (0,1)
A=(0,2) B=(0,0) mp = (0,1)
A=(0,2) B=(0,2) mp = (0,2)
A=(1,0) B=(1,0) mp = (1,0)
A=(1,0) B=(1,2) mp = (1,1)
A=(1,1) B=(1,1) mp = (1,1)
A=(1,2) B=(1,2) mp = (1,2)
A=(1,2) B=(1,0) mp = (1,1)

Now I calculated these manually for the trivial input. How can I calculate this for any set of input? Thanks in advance.

1

There are 1 best solutions below

0
On

The original problem is very difficult to give a general formula for and so I will instead give an upper bound for the number.

If all your numbers are of the form $(a,b)$ where $a,b\in \mathbb Z$ then divide your set into four subsets depending on the parity of $a$ and $b$ (one subset where $a$ is even and $b$ is even, another where $a$ is even and $b$ is odd etc).

Then the two points you choose have to come from the same subset or it is impossible to have their midpoint in the set. Therefore an upper bound for the number is: $$\sum_{i=1}^{4}x_i^2$$ Where $x_i$ for $i\in [1,2,3,4]$ is the size of the subsets.

For your example this approach works very nicely as the subsets are: $[(0,0),(0,2)],[(1,0),(1,2)],[(1,1)],[(0,2)]$ and so an upper bound for the number of possibilities is $2^2 + 2^2 + 1^2 + 1^2 = 10$ which turns out to be the correct answer.