What is known about the complexity of and/or practical algorithms for reporting all triplets of points from finite set of at least four points of which no three are collinear in the Euclidean plane, that define a triangle that contains exactly one point from the set in its interior, i.e. whose barycentric coordinates are strictly positive?


after further thinking about the problem, I tend to believe that $O(n^4)$ is the best time complexity possible.

That conclusion comes from the observation, that the inner point $D$ is adjacent to three empty triangles $\Delta_{ABD},\,\Delta_{BCD},\Delta_{CAD}$ and the lower bound for enumerating all empty triangles can be done in $O(n^3)$ as described in Searching for Empty Convex Polygons; in that algorithm a starshaped polygon $P^*_D$ is described, whose edges are visible from a given point $D$ that shall in this question be the inner point of otherwise empty triangles.

The problem of reporting all triangles with unique interior point $D$ would then amount to reporting all directed triangles with their open arcs inside $P^*_D$; the directed graph that contains those triangles corresponds to the visibility graph of $P^*_D$ with arcs corresponding to edges oriented to render $D$ to their left.

Beating the $O(n^4)$ conjectured lower bound would require a sublinear-time algorithm for reporting all directed triangles in an oriented visibility graph of a star-shaped polygon, which doubt is possible.

elaborating on the partitioning idea that Joseph O'Rourke sketched in his comment and combining it with utilizing empty triangles $\Delta_{ABD}$ to identify candidate points $C$ that could define a triangle $\Delta_{ABC}$ with unique innr point $D$, one finds that all solid points outside the shaded empty triangle qualify:
enter image description here

From the picture it can be clearly seen that the set of solid points contains all points that augment the shaded empty triangle to one with unique interior point.

  • $\begingroup$ It is not inconceivable that $O(n^3 \log n)$ suffices. Let $L$ be a line through a pair of points: $O(n^2)$. Sort the points by distance to $L$: $O(n \log n)$. Sweep through the points with a line parallel to $L$: $O(n)$. Somehow(!) spend $O(\log n)$ determining if $\Delta$ is empty. I don't see that last $\log n$, but there might be a way... $\endgroup$ Commented Jan 5, 2020 at 14:15
  • $\begingroup$ I just learned that the notion of Simplicial Depth is concerned with counting the triangles containing a point. So the question is the opposite in counting the points contained in a triangle (and reporting the triangles that contain only one). $\endgroup$ Commented Feb 22, 2020 at 6:46

2 Answers 2


If one arranges $n+1$ points as illustrated below, then there are $n^3/9 = \Omega(n^3)$ triangles each of which includes exactly one point in its interior. So no algorithm can beat $O(n^3)$ in the worst case.

          Triangles with corners in sets $A,B,C$ include the centerpoint.

  • 1
    $\begingroup$ General position often includes "no four points on a circle", so you might mention that an epsilon variation of your picture provides a cubic lower bound example. Gerhard "Just Slightly Off Of Circumference" Paseman, 2020.01.03. $\endgroup$ Commented Jan 3, 2020 at 15:46
  • $\begingroup$ @GerhardPaseman: Thanks for mentioning that. $\endgroup$ Commented Jan 3, 2020 at 16:16
  • 1
    $\begingroup$ My "in general position" is to be interpreted as "no three collinear" and is intended to guarantee that no side of a triangle contains an interior point. An $O(n^3)$ would be much better than the naive $O(n^4)$ algorithm of checking every quadruplet of points. $\endgroup$ Commented Jan 4, 2020 at 8:55

Given any two points $p$ and $q$, consider the points above line $pq$. You want to list all points $r$ such that $pqr$ contains exactly one additional point. To do so, sort the points radially around $p$ and around $q$. For each $r$, the points that are contained by $pqr$ are the ones that are (strictly) later than $r$ in the $p$-order, and earlier than $r$ in the $q$-order. Or, if we use position in the two orderings as Cartesian coordinates (with tied points being given equal positions), it's the number of points in the quadrant below and to the left of $r$.

So, for these Cartesian points, compute the lower left frontier (the points with nothing strictly below and left of them) and the second frontier behind that (the points with only lower left frontier points strictly below and left of them). These are standard computations that can be done in time $O(n\log n)$. Only the second frontier points can defined the triangles you're looking for: first frontier points have nothing interior to their triangles and points beyond the second frontier contain at least two points (at least one from each of the first two frontiers). For each second frontier point, binary search to find the range of first-frontier points contained in its quadrant, and return the ones where this range consists of exactly one point.

Repeating this for all $p$ and $q$ gives $O(n^3\log n)$. You can get rid of the logs on the frontier calculations by re-using the cyclic orderings around each point rather than separately computing them for each $(p,q)$ pair, and replace the binary searches by two merge computations on the two frontiers (one to find the left end of each range and another to find the right) to reduce this to $O(n^3)$. And, as you've already determined, the output size can be $\Omega(n^3)$.

  • $\begingroup$ "sort the points radially": Beautiful, David! This is what I was missing. And: "re-using the cyclic orderings around each point rather than separately computing them"--Nice! $\endgroup$ Commented Jan 5, 2020 at 22:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.