<s>
In	O
computational	O
geometry	O
,	O
Chan	B-Algorithm
's	I-Algorithm
algorithm	I-Algorithm
,	O
named	O
after	O
Timothy	O
M	O
.	O
Chan	O
,	O
is	O
an	O
optimal	O
output-sensitive	B-Language
algorithm	I-Language
to	O
compute	O
the	O
convex	O
hull	O
of	O
a	O
set	O
of	O
points	O
,	O
in	O
2	O
-	O
or	O
3-dimensional	O
space	O
.	O
</s>
<s>
In	O
the	O
planar	O
case	O
,	O
the	O
algorithm	O
combines	O
an	O
algorithm	O
(	O
Graham	B-Algorithm
scan	I-Algorithm
,	O
for	O
example	O
)	O
with	O
Jarvis	B-Algorithm
march	I-Algorithm
(	O
)	O
,	O
in	O
order	O
to	O
obtain	O
an	O
optimal	O
time	O
.	O
</s>
<s>
Chan	B-Algorithm
's	I-Algorithm
algorithm	I-Algorithm
is	O
notable	O
because	O
it	O
is	O
much	O
simpler	O
than	O
the	O
Kirkpatrick	B-Algorithm
–	I-Algorithm
Seidel	I-Algorithm
algorithm	I-Algorithm
,	O
and	O
it	O
naturally	O
extends	O
to	O
3-dimensional	O
space	O
.	O
</s>
<s>
For	O
each	O
subset	O
,	O
it	O
computes	O
the	O
convex	O
hull	O
,	O
,	O
using	O
an	O
algorithm	O
(	O
for	O
example	O
,	O
Graham	B-Algorithm
scan	I-Algorithm
)	O
,	O
where	O
is	O
the	O
number	O
of	O
points	O
in	O
the	O
subset	O
.	O
</s>
<s>
During	O
the	O
second	O
phase	O
,	O
Jarvis	B-Algorithm
's	I-Algorithm
march	I-Algorithm
is	O
executed	O
,	O
making	O
use	O
of	O
the	O
precomputed	O
(	O
mini	O
)	O
convex	O
hulls	O
,	O
.	O
</s>
<s>
At	O
each	O
step	O
in	O
this	O
Jarvis	B-Algorithm
's	I-Algorithm
march	I-Algorithm
algorithm	O
,	O
we	O
have	O
a	O
point	O
in	O
the	O
convex	O
hull	O
(	O
at	O
the	O
beginning	O
,	O
may	O
be	O
the	O
point	O
in	O
with	O
the	O
lowest	O
y	O
coordinate	O
,	O
which	O
is	O
guaranteed	O
to	O
be	O
in	O
the	O
convex	O
hull	O
of	O
)	O
,	O
and	O
need	O
to	O
find	O
a	O
point	O
such	O
that	O
all	O
other	O
points	O
of	O
are	O
to	O
the	O
right	O
of	O
the	O
line	O
,	O
where	O
the	O
notation	O
simply	O
means	O
that	O
the	O
next	O
point	O
,	O
that	O
is	O
,	O
is	O
determined	O
as	O
a	O
function	O
of	O
and	O
.	O
</s>
<s>
Then	O
,	O
we	O
can	O
determine	O
using	O
the	O
same	O
technique	O
as	O
normally	O
used	O
in	O
Jarvis	B-Algorithm
's	I-Algorithm
march	I-Algorithm
,	O
but	O
only	O
considering	O
the	O
points	O
(	O
i.e.	O
</s>
<s>
For	O
those	O
points	O
,	O
one	O
iteration	O
of	O
Jarvis	B-Algorithm
's	I-Algorithm
march	I-Algorithm
is	O
which	O
is	O
negligible	O
compared	O
to	O
the	O
computation	O
for	O
all	O
subsets	O
.	O
</s>
<s>
Jarvis	B-Algorithm
's	I-Algorithm
march	I-Algorithm
completes	O
when	O
the	O
process	O
has	O
been	O
repeated	O
times	O
(	O
because	O
,	O
in	O
the	O
way	O
Jarvis	B-Algorithm
march	I-Algorithm
works	O
,	O
after	O
at	O
most	O
iterations	O
of	O
its	O
outermost	O
loop	O
,	O
where	O
is	O
the	O
number	O
of	O
points	O
in	O
the	O
convex	O
hull	O
of	O
,	O
we	O
must	O
have	O
found	O
the	O
convex	O
hull	O
)	O
,	O
hence	O
the	O
second	O
phase	O
takes	O
time	O
,	O
equivalent	O
to	O
time	O
if	O
is	O
close	O
to	O
(	O
see	O
below	O
the	O
description	O
of	O
a	O
strategy	O
to	O
choose	O
such	O
that	O
this	O
is	O
the	O
case	O
)	O
.	O
</s>
<s>
In	O
that	O
case	O
,	O
after	O
steps	O
in	O
the	O
second	O
phase	O
,	O
we	O
interrupt	O
the	O
Jarvis	B-Algorithm
's	I-Algorithm
march	I-Algorithm
as	O
running	O
it	O
to	O
the	O
end	O
would	O
take	O
too	O
much	O
time	O
.	O
</s>
<s>
To	O
generalize	O
this	O
construction	O
for	O
the	O
3-dimensional	O
case	O
,	O
an	O
algorithm	O
to	O
compute	O
the	O
3-dimensional	O
convex	O
hull	O
by	O
Preparata	O
and	O
Hong	O
should	O
be	O
used	O
instead	O
of	O
Graham	B-Algorithm
scan	I-Algorithm
,	O
and	O
a	O
3-dimensional	O
version	O
of	O
Jarvis	B-Algorithm
's	I-Algorithm
march	I-Algorithm
needs	O
to	O
be	O
used	O
.	O
</s>
<s>
To	O
fully	O
understand	O
the	O
following	O
pseudocode	O
,	O
it	O
is	O
recommended	O
that	O
the	O
reader	O
is	O
already	O
familiar	O
with	O
Graham	B-Algorithm
scan	I-Algorithm
and	O
Jarvis	B-Algorithm
march	I-Algorithm
algorithms	O
to	O
compute	O
the	O
convex	O
hull	O
,	O
,	O
of	O
a	O
set	O
of	O
points	O
,	O
</s>
<s>
(	O
is	O
used	O
in	O
the	O
Jarvis	B-Algorithm
march	I-Algorithm
part	O
of	O
this	O
Chan	B-Algorithm
's	I-Algorithm
algorithm	I-Algorithm
,	O
</s>
<s>
(	O
For	O
more	O
info	O
,	O
see	O
the	O
comments	O
close	O
to	O
the	O
corresponding	O
part	O
of	O
the	O
Chan	B-Algorithm
's	I-Algorithm
algorithm	I-Algorithm
.	O
)	O
</s>
<s>
(	O
is	O
required	O
for	O
this	O
Chan	B-Algorithm
's	I-Algorithm
algorithm	I-Algorithm
to	O
find	O
the	O
convex	O
hull	O
of	O
.	O
)	O
</s>
<s>
and	O
so	O
that	O
the	O
time	O
complexity	O
of	O
this	O
Chan	B-Algorithm
's	I-Algorithm
algorithm	I-Algorithm
is	O
.	O
)	O
</s>
<s>
(	O
Nevertheless	O
,	O
this	O
Chan	B-Algorithm
's	I-Algorithm
algorithm	I-Algorithm
stops	O
once	O
iterations	O
of	O
the	O
outermost	O
loop	O
are	O
performed	O
,	O
</s>
<s>
(	O
For	O
more	O
info	O
,	O
see	O
the	O
Jarvis	B-Algorithm
march	I-Algorithm
part	O
of	O
this	O
algorithm	O
below	O
,	O
where	O
is	O
returned	O
if	O
.	O
)	O
</s>
<s>
If	O
the	O
"	O
doubling	O
scheme	O
"	O
is	O
used	O
,	O
though	O
,	O
the	O
resulting	O
time	O
complexity	O
of	O
this	O
Chan	B-Algorithm
's	I-Algorithm
algorithm	I-Algorithm
is	O
.	O
)	O
</s>
<s>
(	O
Compute	O
the	O
convex	O
hull	O
of	O
subset	O
,	O
,	O
using	O
Graham	B-Algorithm
scan	I-Algorithm
,	O
which	O
takes	O
time	O
.	O
)	O
</s>
<s>
(	O
Now	O
,	O
use	O
a	O
modified	O
version	O
of	O
the	O
Jarvis	B-Algorithm
march	I-Algorithm
algorithm	O
to	O
compute	O
the	O
convex	O
hull	O
of	O
.	O
)	O
</s>
<s>
(	O
Jarvis	B-Algorithm
march	I-Algorithm
performs	O
in	O
time	O
,	O
where	O
is	O
the	O
number	O
of	O
input	O
points	O
and	O
is	O
the	O
number	O
of	O
points	O
in	O
the	O
convex	O
hull	O
.	O
)	O
</s>
<s>
(	O
Given	O
that	O
Jarvis	B-Algorithm
march	I-Algorithm
is	O
an	O
output-sensitive	B-Language
algorithm	I-Language
,	O
its	O
running	O
time	O
depends	O
on	O
the	O
size	O
of	O
the	O
convex	O
hull	O
,	O
.	O
)	O
</s>
<s>
(	O
In	O
practice	O
,	O
it	O
means	O
that	O
Jarvis	B-Algorithm
march	I-Algorithm
performs	O
iterations	O
of	O
its	O
outermost	O
loop	O
.	O
</s>
<s>
(	O
In	O
this	O
modified	O
version	O
of	O
Jarvis	B-Algorithm
march	I-Algorithm
,	O
we	O
perform	O
an	O
operation	O
inside	O
the	O
innermost	O
loop	O
which	O
takes	O
time	O
.	O
</s>
<s>
(	O
Jarvis	B-Algorithm
march	I-Algorithm
terminates	O
when	O
the	O
next	O
selected	O
point	O
on	O
the	O
convext	O
hull	O
,	O
,	O
is	O
the	O
initial	O
point	O
,	O
.	O
)	O
</s>
<s>
Computing	O
the	O
lower	B-Algorithm
envelope	I-Algorithm
of	O
a	O
set	O
of	O
line	O
segments	O
,	O
which	O
is	O
defined	O
as	O
the	O
lower	O
boundary	O
of	O
the	O
unbounded	O
trapezoid	O
of	O
formed	O
by	O
the	O
intersections	O
.	O
</s>
