Consider a set $A$ that contains a collection of points $(x_{1},y_{1}),…,(x_{n},y_{n})$. Then, we can define a convex hull from $A$ as

$Convex-Hull(A)={z=(x,y)∈{R}_{2}∣zis an average of points inA}$A given point $i$ gets a weight $w_{i}≥0$ such that $∑_{i=1}w_{i}=1$ and $z=∑_{i=1}w_{i}⋅(x_{i},y_{i})$.

Another definition of a convex hull is to consider the set of points that make up the boundary of the convex hull. Then, a segment makes up part of the boundary if and only if there does not exist points on both sides of the segment, if we extended the ends towards infinity.

If points existed on both sides then we’re not bounding/enclosing the points and therefore this is not a boundary.

Problem

Input:list of points $A$.

Output:a description of $A$‘s convex hull, as a sequence of points $(a_{1},b_{1}),…,(a_{k},b_{k})$ that describe the boundary in a counter-clockwise order.

## Naive algorithm

For each pair of points, we draw a segment between them, and then check if there exists points on both sides of the segment. If so, then it’s not a boundary. Otherwise, it is.

This algorithm runs in $O(n_{3})$, because there are $(2n )=O(n_{2})$ pairs of points and it takes $O(n)$ time to check every point for each segment.

## What makes divide and conquer applicable?

We make the claim that $A$ can be divided into two sets of points such that $A=A_{1}∪A_{2}$. Then, we claim that

$Convex-Hull(Convex-Hull(A_{1})∪Convex-Hull(A_{2}))=Convex-Hull(A)$## First attempt at D&C algorithm

We only need to create/add two segments between $A_{1}$ and $A_{2}$ in order to merge them.

Consider the line $l$ that we’re using to divide $A$ into two. For each two points, one from $A_{1}$ and one from $A_{2}$, we check if the intersection of the line is the highest point on $l$.

We do the symmetric thing for the minimum as well. find the lowest intersection on $l$.

Once again we’re doing $(2n )=O(n_{2})$. The recurrence relation is then given by $T(n)=2T(2n )+O(n_{2})$. By the Master theorem, this recurrence simplifies to $O(n_{2})$, which is an improvement

## Better merge step

The issue is that the merging takes $O(n_{2})$ in our previous attempt. To hit a runtime of $O(ngn)$, our budget needs to fit in $O(n)$ time.