Convex Hull — Andrew's Monotone Chain

Sort by (x, y), sweep twice, pop non-left turns using the cross-product orientation test.

orient: O(1) monotone chain: O(n log n) space: O(n) lower bound: Ω(n log n)

Point Plane

slow fast
point on stack pushing popped (dent) candidate C hull vertex

Orientation Test

Step: 0/0 Phase: Pops: 0 Stack: 0
Press Run to animate, or Step one at a time.
Each step shows cross(A,B,C) and its sign.

Complexity

AlgorithmTimeSpace
Monotone chainO(n log n)O(n)
Graham scanO(n log n)O(n)
Gift wrappingO(n·h)O(n)
QuickHull (avg)O(n log n)O(n)
QuickHull (worst)O(n²)O(n)
Chan's algorithmO(n log h)O(n)
orient (1 test)O(1)O(1)

Operation Log