Why it matters

Convex hull is foundational computational geometry. Understanding enables geometric problems.

Advertisement

The architecture

Graham scan: sort by angle from lowest point; add points; pop when turn wrong direction.

Andrew's monotone chain: sort by x; construct upper + lower hulls.

Convex hull algorithmsSort pointsby angle or xTraverse + maintainconvex propertyResulthull pointsCross product determines turn direction: positive = left turn, negative = right
Convex hull construction.
Advertisement

How it works end to end

Cross product: (b-a) × (c-b). Sign indicates turn direction.

Complexity: O(n log n) for sort-based; O(nh) for gift wrapping (h = hull size).

3D + higher: much harder; use library.