Convex Hulls and Sorting
- In the previous example, we saw a convex hull algorithm that performed in $O(n log_2 n) time.
- Should we look for a better algorithm?
- Consider any list of numbers L = $\{a_1, a_2, ... a_n\}$
- For simplicity assume there are no duplicates.
- Form a set of points P = $\{(a_1, a_1^2), (a_2, a_2^2), ... (a_n, a_n^2)\}$
- Note: This can be done in polynomial time.
- Actually O(n) which is important here.
- What will finding the convex hull of P produce?
- A graph of P will be a parabola.
- And the convex hull will provide the ordering of the points.
- Or finding the convex hull will "sort" L.
- So there is no point in looking for a faster convex hull solution
- If one existed, then we could do the "convex hull" sort.
- But I lie, there is actually a faster one, but it depends on the number of points on the hull (h), and is $O(nh)$.
- But that would be $O(n^2)$ for sorting a list of unique numbers.
- This is the general idea of a reduction.
- Converting one problem to another so that if you find the solution to the second, you have the solution to the first.
- Notation: A polynomial time reduction from $L_1$ to $L_2$ is written $L_1 \le_P L_2$
- This means
- mapping the input for $L_1$ to input to $L_2$,
- Use $L_2$ to solve the problem for the mapped input
- Then use this solution to solve the $L_1$ problem for the given input.
- And implies that $L_1$ is no harder than $L_2$.
- In our case we can
- Map from sorting to convex hull in linear time.
- Solve the convex hull in $O(n log_2 n)$
- Map back in linear time.