<s>
In	O
computer	O
science	O
,	O
adaptive	B-Application
heap	I-Application
sort	I-Application
is	O
a	O
comparison-based	B-Algorithm
sorting	B-Algorithm
algorithm	I-Algorithm
of	O
the	O
adaptive	B-Algorithm
sort	I-Algorithm
family	I-Algorithm
.	O
</s>
<s>
It	O
is	O
a	O
variant	O
of	O
heap	B-Application
sort	I-Application
that	O
performs	O
better	O
when	O
the	O
data	O
contains	O
existing	O
order	O
.	O
</s>
<s>
Instead	O
of	O
putting	O
all	O
the	O
data	O
into	O
the	O
heap	O
as	O
the	O
traditional	O
heap	B-Application
sort	I-Application
did	O
,	O
adaptive	B-Application
heap	I-Application
sort	I-Application
only	O
take	O
part	O
of	O
the	O
data	O
into	O
the	O
heap	O
so	O
that	O
the	O
run	O
time	O
will	O
reduce	O
significantly	O
when	O
the	O
presortedness	O
of	O
the	O
data	O
is	O
high	O
.	O
</s>
<s>
Heap	B-Application
sort	I-Application
is	O
a	O
sorting	B-Algorithm
algorithm	I-Algorithm
that	O
utilizes	O
binary	B-Application
heap	I-Application
data	O
structure	O
.	O
</s>
<s>
The	O
method	O
treats	O
an	O
array	O
as	O
a	O
complete	O
binary	O
tree	O
and	O
builds	O
up	O
a	O
Max-Heap/Min	O
-Heap	O
to	O
achieve	O
sorting	B-Algorithm
.	O
</s>
<s>
These	O
measures	O
of	O
presortedness	O
decides	O
the	O
number	O
of	O
data	O
that	O
will	O
be	O
put	O
in	O
to	O
the	O
heap	O
during	O
the	O
sorting	B-Algorithm
process	O
as	O
well	O
as	O
the	O
lower	O
bound	O
of	O
running	O
time	O
.	O
</s>
<s>
Most	O
of	O
these	O
different	O
measurements	O
are	O
related	O
for	O
adaptive	B-Application
heap	I-Application
sort	I-Application
.	O
</s>
<s>
Adaptive	B-Application
heap	I-Application
sort	I-Application
is	O
a	O
variant	O
of	O
heap	B-Application
sort	I-Application
that	O
seeks	O
optimality	O
(	O
asymptotically	O
optimal	O
)	O
with	O
respect	O
to	O
the	O
lower	O
bound	O
derived	O
with	O
the	O
measure	O
of	O
presortedness	O
by	O
taking	O
advantage	O
of	O
the	O
existing	O
order	O
in	O
the	O
data	O
.	O
</s>
<s>
In	O
heap	B-Application
sort	I-Application
,	O
for	O
a	O
data	O
,	O
we	O
put	O
all	O
n	O
elements	O
into	O
the	O
heap	O
and	O
then	O
keep	O
extracting	O
the	O
maximum	O
(	O
or	O
minimum	O
)	O
for	O
n	O
times	O
.	O
</s>
<s>
Since	O
the	O
time	O
of	O
each	O
max-extraction	O
action	O
is	O
the	O
logarithmic	O
in	O
the	O
size	O
of	O
the	O
heap	O
,	O
the	O
total	O
running	O
time	O
of	O
standard	O
heap	B-Application
sort	I-Application
is	O
.	O
</s>
<s>
For	O
adaptive	B-Application
heap	I-Application
sort	I-Application
,	O
instead	O
of	O
putting	O
all	O
the	O
elements	O
into	O
the	O
heap	O
,	O
only	O
the	O
possible	O
maximums	O
of	O
the	O
data	O
(	O
max-candidates	O
)	O
will	O
be	O
put	O
into	O
the	O
heap	O
so	O
that	O
fewer	O
runs	O
are	O
required	O
when	O
each	O
time	O
we	O
try	O
to	O
locate	O
the	O
maximum	O
(	O
or	O
minimum	O
)	O
.	O
</s>
<s>
First	O
,	O
a	O
Cartesian	B-Algorithm
tree	I-Algorithm
is	O
built	O
from	O
the	O
input	O
in	O
time	O
by	O
putting	O
the	O
data	O
into	O
a	O
binary	O
tree	O
and	O
making	O
each	O
node	O
in	O
the	O
tree	O
is	O
greater(or smaller )	O
than	O
all	O
its	O
children	O
nodes	O
,	O
and	O
the	O
root	O
of	O
the	O
Cartesian	B-Algorithm
tree	I-Algorithm
is	O
inserted	O
into	O
an	O
empty	O
binary	B-Application
heap	I-Application
.	O
</s>
<s>
Then	O
repeatedly	O
extract	O
the	O
maximum	O
from	O
the	O
binary	B-Application
heap	I-Application
,	O
retrieve	O
the	O
maximum	O
in	O
the	O
Cartesian	B-Algorithm
tree	I-Algorithm
,	O
and	O
add	O
its	O
left	O
and	O
right	O
children	O
(	O
if	O
any	O
)	O
which	O
are	O
themselves	O
Cartesian	B-Algorithm
trees	I-Algorithm
,	O
to	O
the	O
binary	B-Application
heap	I-Application
.	O
</s>
<s>
If	O
the	O
input	O
is	O
already	O
nearly	O
sorted	O
,	O
the	O
Cartesian	B-Algorithm
trees	I-Algorithm
will	O
be	O
very	O
unbalanced	O
,	O
with	O
few	O
nodes	O
having	O
left	O
and	O
right	O
children	O
,	O
resulting	O
in	O
the	O
binary	B-Application
heap	I-Application
remaining	O
small	O
,	O
and	O
allowing	O
the	O
algorithm	O
to	O
sort	O
more	O
quickly	O
than	O
for	O
inputs	O
that	O
are	O
already	O
nearly	O
sorted	O
.	O
</s>
<s>
Despite	O
decades	O
of	O
research	O
,	O
there	O
's	O
still	O
a	O
gap	O
between	O
the	O
theory	O
of	O
adaptive	B-Application
heap	I-Application
sort	I-Application
and	O
its	O
practical	O
use	O
.	O
</s>
<s>
Because	O
the	O
algorithm	O
makes	O
use	O
of	O
Cartesian	B-Algorithm
trees	I-Algorithm
and	O
pointer	O
manipulation	O
,	O
it	O
has	O
low	O
cache-efficiency	O
and	O
high	O
memory	O
requirements	O
,	O
both	O
of	O
which	O
deteriorate	O
the	O
performance	O
of	O
implementations	O
.	O
</s>
