GRAHAM_SCAN(P)
- Let p0 be the point in P with the minimum y-coordinate, select the leftmost in the case of a tie.
- Sort the remaining points by polar angle with p0
- S.push(p0)
- S.push(p1)
- S.push(p2)
- for i ← 3 to n do
- while the angle formed by S.top(), S.next_to_top() and pi make a nonleft turn
- S.pop()
- S.push(pi)
- return S