The algorithm presented assumes two things:
To get around the second problem, we modify the algorithm somewhat. The main idea is to compute a point on the hull (say the one with minimal y coordinate). All the points are sorted with respect to this point on the hull. We label the points based on this sorting and use it to initialize two points on the stack.
The modified version of Graham's algorithm is:
Algorithm
Find rightmost lowest point; label it .
Sort all other points angularly about ,
break ties in favor of closeness to
;
label
.
Stack
; t indexes top
i = 1
while do
if
is left of
then Push(
and
increment i.
else Pop(
.
Its complexity is .