<p>Points with the same x-coordinate do not cause any substantial problem.  However, if you implement the divide-and-conquer algorithm carelessly, they may cause a problem.  One way to deal with them is by using <a href="http://books.google.ca/books?id=tkyG8W2163YC&amp;ots=4GN9qE11mS&amp;dq=symbolic%20perturbation&amp;pg=PA137">symbolic perturbation</a>.</p>

CC BY-SA 4.0
2022-06-22T17:35:00.343Z
I feel like an explanation of how the algorithm degenerates, and how to avoid it, is missing for this to be an answer.
Bladt
CC BY-SA 4.0
2022-06-23T01:49:55.003Z
This is a technical issue that can be dealt with more easily than with symbolic perturbation in this case. On the other hand this is not a research level question. I can imagine this being an exercise in an algorithms class after teaching the closest pair divide and conquer algorithm.
Chandra Chekuri
CC BY-SA 3.0
2011-11-17T23:20:33.010Z
2011-11-17T23:20:33.010Z
Tsuyoshi Ito
<p>The input then is boring, and the algorithm is bored it takes it much longer to solve the problem.</p>

CC BY-SA 3.0
2011-11-18T00:19:17.410Z
[There is no such thing as a boring input](http://en.wikipedia.org/wiki/Interesting_number_paradox).
Tsuyoshi Ito
CC BY-SA 3.0
2011-11-22T09:51:52.280Z
**Theorem:** There is no such thing as an interesting natural number.  **Proof:** Let n be the smallest interesting natural number.  Who cares?  QED.
Jeffε
CC BY-SA 3.0
2011-11-17T21:40:41.977Z
2011-11-17T21:40:41.977Z
Sariel Har-Peled
<p>Without the assumption that no points share the same x-coordinate, we run into one of two problems:</p>
<p>One problem occurs if you partition the space by x-coordinate. Say all points have the same x-coordinate. Any partitioning-value will group all points into the same partition. Clearly this means our depth of recursion is not bounded at O(log n) (depending on the exact implementation, this case might never terminate).</p>
<p>If you try to avoid that problem, by partitioning by position in the sorted list instead, you run into problems with the correctness of of the algorithm: You have to deal with the possibility that there can be points in one partition with the same coordinates as a point in the other.</p>
<p>I haven't read the proof for the 7-point the trick, but in Tardos &amp; Kleinberg, they show a proof for a laxer 15 point version of it:
Their proof relies on drawing a dividing line for the partition, given by x=pr_x, where pr_x is the x-coordinate for the right most point in the left partition. They expand the line to a vertical band of width 2d, centered on the line.
d denotes the distance between the closest points found by the recursive calls.
If there's a closer pair that spans our partitions, it must be in this band.</p>
<p>So far so good.</p>
<p>As a step on their way to arrive at the 15 points, they divide the band into an even grid of d/2 by d/2 squares. For the remaining proof, they rely on the claim that no two points can lie in the same square. They prove this by contradiction:</p>
<p>(1) If two points lie in the same square, they must be closer to eachother than d as the squares are d/2 by d/2.
(2) If two points lie in the same square, they must be in the same partition.</p>
<p>If two points in the same partition (2) were closer to eachother than d (1), the recursive call would have returned that pair, and d would have been the distance between them, ie. less than d. A contradiction!</p>
<p>Here's the kicker: What guarantees that two points in the same square are on the same partition? Answer: The fact that no two points have the same x-coordinates.</p>
<p>If, as suggested above, we partition by simply taking half the list of points (+/- 1 for lists of uneven length), we could have two points with the same x coordinate, with one going on the left partition, and the other in the right partition. If these points are the closest pair, we are not guaranteed to find them.</p>
<p>In other words, if we don't assume that no two points have the same coordinates, we need to alter our partitioning method, or amend our proof that we can correctly &quot;merge&quot; the solutions found by recursion, in O(n) time.</p>

CC BY-SA 4.0
2022-06-22T20:30:51.407Z
2022-06-24T07:51:50.557Z
2022-06-24T07:51:50.557Z
Bladt
<p>The <a href="http://en.wikipedia.org/wiki/Closest_pair_of_points_problem" rel="nofollow">closest pair of points</a> problem deals with the task to find a pair of points with the global minimum distance. There is a problem, when all points share the same x-coordinate, or at least a large number of points.</p>

<p>I just don't know why, I heard the running time becomes $n^2$</p>

<p>What about it? What is the problem, since the proof for the algorithm shows, that at max. 8 points can reside in the $2 \delta \times \delta$ area.</p>

CC BY-SA 3.0
2011-11-17T22:12:11.560Z
I think you may be confused.  $n^2$ is brute force...
Lev Reyzin
CC BY-SA 3.0
2011-11-17T22:35:06.327Z
Yes I know that. But if all points share the same x-coordinate, all the points land in the same set in the deivide step, don't they?
GugenMinded
<ds.algorithms><cg.comp-geom><time-complexity>
What is the problem in "closest pair problem" if all points share the same x-coordinate
GugenMinded
# What is the problem in "closest pair problem" if all points share the same x-coordinate

(Asked by: username_0 on 2011-11-17)

The [closest pair of points](http://en.wikipedia.org/wiki/Closest_pair_of_points_problem) problem deals with the task to find a pair of points with the global minimum distance. There is a problem, when all points share the same x-coordinate, or at least a large number of points.

I just don't know why, I heard the running time becomes $n^2$

What about it? What is the problem, since the proof for the algorithm shows, that at max. 8 points can reside in the $2 \delta \times \delta$ area.

**Tags:** ds.algorithms, cg.comp-geom, time-complexity

> **Comments:**
> **username_1**: I think you may be confused.  $n^2$ is brute force...  
> **username_0**: Yes I know that. But if all points share the same x-coordinate, all the points land in the same set in the deivide step, don't they?  

---

## 3 answers

### Answer by username_2 on 2011-11-17. Score: 5 | Accepted answer

Points with the same x-coordinate do not cause any substantial problem. However, if you implement the divide-and-conquer algorithm carelessly, they may cause a problem. One way to deal with them is by using [symbolic perturbation](http://books.google.ca/books?id=tkyG8W2163YC&ots=4GN9qE11mS&dq=symbolic%20perturbation&pg=PA137).

> **Comments:**
> **username_3**: I feel like an explanation of how the algorithm degenerates, and how to avoid it, is missing for this to be an answer.  
> **username_4**: This is a technical issue that can be dealt with more easily than with symbolic perturbation in this case. On the other hand this is not a research level question. I can imagine this being an exercise in an algorithms class after teaching the closest pair divide and conquer algorithm.  

---

### Answer by username_5 on 2011-11-17. Score: 1

The input then is boring, and the algorithm is bored it takes it much longer to solve the problem.

> **Comments:**
> **username_2**: [There is no such thing as a boring input](http://en.wikipedia.org/wiki/Interesting_number_paradox).  
> **username_6**: **Theorem:** There is no such thing as an interesting natural number.  **Proof:** Let n be the smallest interesting natural number.  Who cares?  QED.  

---

### Answer by username_3 on 2022-06-22. Score: 1

Without the assumption that no points share the same x-coordinate, we run into one of two problems:

One problem occurs if you partition the space by x-coordinate. Say all points have the same x-coordinate. Any partitioning-value will group all points into the same partition. Clearly this means our depth of recursion is not bounded at O(log n) (depending on the exact implementation, this case might never terminate).

If you try to avoid that problem, by partitioning by position in the sorted list instead, you run into problems with the correctness of of the algorithm: You have to deal with the possibility that there can be points in one partition with the same coordinates as a point in the other.

I haven't read the proof for the 7-point the trick, but in Tardos & Kleinberg, they show a proof for a laxer 15 point version of it:
Their proof relies on drawing a dividing line for the partition, given by x=pr\_x, where pr\_x is the x-coordinate for the right most point in the left partition. They expand the line to a vertical band of width 2d, centered on the line.
d denotes the distance between the closest points found by the recursive calls.
If there's a closer pair that spans our partitions, it must be in this band.

So far so good.

As a step on their way to arrive at the 15 points, they divide the band into an even grid of d/2 by d/2 squares. For the remaining proof, they rely on the claim that no two points can lie in the same square. They prove this by contradiction:

(1) If two points lie in the same square, they must be closer to eachother than d as the squares are d/2 by d/2.
(2) If two points lie in the same square, they must be in the same partition.

If two points in the same partition (2) were closer to eachother than d (1), the recursive call would have returned that pair, and d would have been the distance between them, ie. less than d. A contradiction!

Here's the kicker: What guarantees that two points in the same square are on the same partition? Answer: The fact that no two points have the same x-coordinates.

If, as suggested above, we partition by simply taking half the list of points (+/- 1 for lists of uneven length), we could have two points with the same x coordinate, with one going on the left partition, and the other in the right partition. If these points are the closest pair, we are not guaranteed to find them.

In other words, if we don't assume that no two points have the same coordinates, we need to alter our partitioning method, or amend our proof that we can correctly "merge" the solutions found by recursion, in O(n) time.


---

