Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 1d 16h 01m 36s1 days 16 hours 1 minutes 36 seconds.
Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 1d 16h 01m 36s1 days 16 hours 1 minutes 36 seconds.

Sign in to watch this lesson
Advanced - Geometry · 4:16
The convex hull is the smallest convex polygon containing a point set. Graham's scan takes the lowest point P0, sorts the rest by angle with cross products and keeps a stack that pops every point where the chain fails to turn left; Andrew's monotone chain gets the same hull from a plain (x, y) sort with a lower and an upper pass. Both cost O(n log n) for the sort plus O(n) for the stack, and the pop condition (≤ 0 or < 0) decides whether points on hull edges are kept, with all-collinear inputs handled separately.