Convex Hull
Convex Hull
Convex Hull
A set S in a vector space is convex if, for any two points x, y ∈ S, the line segment joining x and
y is entirely contained within S. Formally, S is convex if for all x, y ∈ S and λ ∈ [0, 1], the point
λx + (1 − λ)y ∈ S.
For example the set X shown below is convex because you can take any two points in the set and
join a straight line between them such that all points on the line belong to the set X, Set Y is not
convex because the line joining points A and B have some points that are not contained within the
set Y .
Problem 1. Identify Convex and non Convex set from the following illustrations. [2 marks]
Figure 2: Examples
2 Convex Hull
Definition 1. The smallest convex set refers to the minimal convex boundary that encloses all the
points, meaning there is no other convex set with a smaller area (or volume in higher dimensions)
that still contains all the points.
1
Figure 3: If we needed to find the convex hull for the points given above, simply joining the points
one by one does not suffice as the line joining the two points shown in purple lies entirely outside
the set and hence the above boundary of the points doesnt represent a convex hull
Problem 2. Show that the convex hull of a finite set of points (more than two points) is a convex
polygon. You can assume that the points are non-collinear. [5 marks]
Solution.
Visual illustrations of convex hulls. Let’s have a look to see how to make convex hull for a
given points.
2
Problem 3. Find the convex hull of the set of points {(0, 0), (1, 1), (2, 2), (1, 0), (2, 1)}. Do this by
drawing the convex hull for this point set. [3 marks]
Solution.
2.2.1 Minimality
Problem 4. Prove that the convex hull of a set of points is minimal. [3 marks]
Solution.
Problem 5. Prove that the convex hull is the intersection of all convex sets containing a given set.
[3 marks]
Solution.
2.2.3 Uniqueness
Problem 6. Prove that the convex hull of a set of points is unique. [3 marks]
Solution.
Problem 7. Split a given set of points {(0, 0), (1, 1), (2, 2), (1, 0), (2, 1)} into two subsets by a vertical
line. Some considerations when you are splitting:
1. Avoid Collinearity: Ensure the line doesn’t overlap any points you want to separate.
2. Subset Sizes: Decide if you want equal-sized subsets or if different sizes are acceptable.
3. Boundary Conditions: Determine whether points on the line belong to the left or right subset.
[5 marks]
3
Solution.
Problem 8. Why is it necessary to divide the points with respect to the median and not the mean?
[4 marks]
Solution.
Definition 2 (The Upper Tangent). The upper tangent between two convex hulls is the line segment
that touches both hulls at exactly one point each and lies above all other points in both hulls.
Upper Tangent
Hull B
Hull A
Definition 3 (The Lower Tangent). Similarly, the lower tangent is the line segment that touches
both hulls at exactly one point each and lies below all other points in both hulls.
Lower Tangent
Hull B
Hull A
Problem 9. Given the following code to merge convex hulls including the code for the upper tangent,
write the code finding the lower tangent. [8 marks]
4
Algorithm 1 Convex Hull Merging Process
1: Input: Two convex hulls, Hull A and Hull B
2: Output: Merged convex hull
3: procedure FindUpperTangent(Hull A, Hull B)
4: Set i = index of the rightmost point of Hull A
5: Set j = index of the leftmost point of Hull B
6: while line segment (Hull A[i], Hull B[j]) is not an upper tangent do
7: if not an upper tangent for Hull A then
8: Move i counterclockwise in Hull A
9: else if not an upper tangent for Hull B then
10: Move j clockwise in Hull B
11: return (Hull A[i], Hull B[j]) as the upper tangent
12: procedure FindLowerTangent(Hull A, Hull B)
13: procedure MergeHulls(Hull A, Hull B)
14: upperT angent ← FindUpperTangent(Hull A, Hull B)
15: lowerT angent ← FindLowerTangent(Hull A, Hull B)
16: Initialize an empty list for the merged hull
17: Traverse points from upperT angent to lowerT angent on Hull A
18: Traverse points from upperT angent to lowerT angent on Hull B
19: return the merged convex hull
Solution.
Problem 10. Given the points (1, 1), (2, 3), (3, 2), (5, 4), (6, 1), and (7, 3), find the upper and
lower tangents between the convex hulls of the sets {(1, 1), (2, 3), (3, 2)} and {(5, 4), (6, 1), (7, 3)}.
For finding the lower tangent, use the algorithm you wrote for the previous question. [10 marks]
Solution.
Problem 11. Merge the convex hulls {(0, 0), (1, 0), (1, 1)} and {(2, 1), (2, 2)} using the algorithm
mentioned above. [10 marks]
Solution.
Problem 12. Why not select the highest point for the upper tangent and the lowest points for the
lower tangent? Why use the mentioned algorithm? [5 marks]
Solution.
Problem 13. Explain why the merging step in the divide and conquer algorithm takes O(n) time.
[3 marks]
Solution.
5
3.1 Divide and Conquer Algorithm
Problem 14. Explain the time complexity of the divide and conquer convex hull algorithm. Break
down the time complexity for each step, including:
[10 marks]
Solution.
Problem 15. Given the recurrence relation for the divide and conquer convex hull algorithm:
n
T (n) = 2T + O(n)
2
Solve this recurrence relation using the Master Theorem to determine the overall time complexity
of the algorithm. [10 marks]
Solution.