Given $N$ points in a plane, find the 2 points that are closest on the plane. $\ell_2$ norm

  1. Sort by $X$ and $Y$ coordinates
  2. Pivot problem into 2 parts along $X$-axis
  3. Recursively solve both parts
  4. Now have smallest distance on both sides, how to find if smallest distance is “cross border”?
    1. On one side, each distance is at least $\delta$. Note that creating a box of $\delta/2$, only one point necessarily is in the box
    2. On each side of the border will be a vertical sequence of border boxes, if there are 2 points on adjacent cross border boxes, there is a smaller cross border distance
    3. Hence, only need to check 10 boxes for each point on 1 side

$T(n)=2T(n/2) + \Theta(n)$ $=\mathcal{O}(n\log n)$

2 Dimensional gift wrapping: find convex wrap around odd shape (Convex hall)

Given $n$ points in $\R^2$, find convex polygon on the boundary

Assume all $x$ and $y$ coordinates are distinct

There are no 3 points on the same line

  1. Divide points by $x$ coordinate
  2. We now have two convex polygons on each side
  3. Create a line between the two polygons, find the highest tangent by rotating counterclockwise and clockwise

NP-Completeness

$P$ is the class of all problems solvable in polynomial time.

Take some verifier $V$ which is some polynomial-time machine.

$NP$ is the class of all problems that are easy to verify in polynomial time. (Using some verifier $V$)

Completeness: if $x\in L$, then $P$ has a $w$ that makes $V$ accept

Soundness: if $x \notin L$, $P$ has no way of convincing $V$ to accept