Skip to main content
3 of 3
More appropriate tags
HEKTO
  • 3.1k
  • 16
  • 19

Closest point on a convex hull in log(n)

We are given a convex polygon $C = \{P_1, P_2, \dots, P_n\}$, where the points are ordered either clockwise or counter-clockwise. Additionally, we have a point $P_\text{new} = (x, y)$ that lies outside the convex hull. The goal is to find the point $P_i$ in $C$ that is closest to $P_\text{new}$ in a logarithmic time complexity. ($O(\log n)$.)

Convex polygon and a point

We can't use sorting because that would take $O(n \log(n))$ time, and also we can't use binary search because of the shape of a convex hull and we might delete the half that contains the answer.

amy
  • 41
  • 1