<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
a	O
shadow	B-Application
heap	I-Application
is	O
a	O
mergeable	B-Application
heap	I-Application
data	B-General_Concept
structure	I-General_Concept
which	O
supports	O
efficient	O
heap	O
merging	O
in	O
the	O
amortized	B-General_Concept
sense	O
.	O
</s>
<s>
More	O
specifically	O
,	O
shadow	B-Application
heaps	I-Application
make	O
use	O
of	O
the	O
shadow	O
merge	O
algorithm	O
to	O
achieve	O
insertion	O
in	O
O(f(n )	O
)	O
amortized	B-General_Concept
time	I-General_Concept
and	O
deletion	O
in	O
O((log n log log n )	O
/f	O
( n	O
)	O
)	O
amortized	B-General_Concept
time	I-General_Concept
,	O
for	O
any	O
choice	O
of	O
1	O
≤	O
f(n )	O
≤	O
log	O
log	O
n	O
.	O
</s>
<s>
Throughout	O
this	O
article	O
,	O
it	O
is	O
assumed	O
that	O
A	O
and	O
B	O
are	O
binary	B-Application
heaps	I-Application
with	O
|A|	O
≤	O
|B|	O
.	O
</s>
<s>
Shadow	O
merge	O
is	O
an	O
algorithm	O
for	O
merging	O
two	O
binary	B-Application
heaps	I-Application
efficiently	O
if	O
these	O
heaps	O
are	O
implemented	O
as	O
arrays	O
.	O
</s>
<s>
We	O
wish	O
to	O
merge	O
the	O
two	O
binary	B-Application
min-heaps	I-Application
and	O
.	O
</s>
<s>
Concatenate	O
the	O
array	B-Data_Structure
at	O
the	O
end	O
of	O
the	O
array	B-Data_Structure
to	O
obtain	O
an	O
array	B-Data_Structure
.	O
</s>
<s>
Extract	O
and	O
sort	O
the	O
smallest	O
nodes	O
from	O
the	O
shadow	O
into	O
an	O
array	B-Data_Structure
.	O
</s>
<s>
If	O
,	O
then	O
starting	O
from	O
the	O
smallest	O
element	O
in	O
the	O
sorted	O
array	B-Data_Structure
,	O
sequentially	O
insert	O
each	O
element	O
of	O
into	O
,	O
replacing	O
them	O
with	O
'	O
s	O
smallest	O
elements	O
.	O
</s>
<s>
Since	O
there	O
are	O
at	O
most	O
2	O
nodes	O
at	O
each	O
level	O
on	O
,	O
then	O
reading	O
the	O
smallest	O
elements	O
of	O
the	O
shadow	O
into	O
the	O
sorted	O
array	B-Data_Structure
takes	O
time	O
.	O
</s>
<s>
A	O
shadow	B-Application
heap	I-Application
consists	O
of	O
threshold	O
function	O
,	O
and	O
an	O
array	B-Data_Structure
for	O
which	O
the	O
usual	O
array-implemented	O
binary	B-Application
heap	I-Application
property	O
is	O
upheld	O
in	O
its	O
first	O
entries	O
,	O
and	O
for	O
which	O
the	O
heap	O
property	O
is	O
not	O
necessarily	O
upheld	O
in	O
the	O
other	O
entries	O
.	O
</s>
<s>
Thus	O
,	O
the	O
shadow	B-Application
heap	I-Application
is	O
essentially	O
a	O
binary	B-Application
heap	I-Application
adjacent	O
to	O
an	O
array	B-Data_Structure
.	O
</s>
<s>
To	O
add	O
an	O
element	O
to	O
the	O
shadow	B-Application
heap	I-Application
,	O
place	O
it	O
in	O
the	O
array	B-Data_Structure
.	O
</s>
<s>
If	O
the	O
array	B-Data_Structure
becomes	O
too	O
large	O
according	O
to	O
the	O
specified	O
threshold	O
,	O
we	O
first	O
build	O
a	O
heap	O
out	O
of	O
using	O
Floyd	O
's	O
algorithm	O
for	O
heap	O
construction	O
,	O
and	O
then	O
merge	O
this	O
heap	O
with	O
using	O
shadow	O
merge	O
.	O
</s>
<s>
Finally	O
,	O
the	O
merging	O
of	O
shadow	B-Application
heaps	I-Application
is	O
simply	O
done	O
through	O
sequential	O
insertion	O
of	O
one	O
heap	O
into	O
the	O
other	O
using	O
the	O
above	O
insertion	O
procedure	O
.	O
</s>
<s>
We	O
are	O
given	O
a	O
shadow	B-Application
heap	I-Application
,	O
with	O
threshold	O
function	O
as	O
above	O
.	O
</s>
<s>
We	O
derive	O
the	O
desired	O
running	O
time	O
bounds	O
for	O
the	O
mergeable	B-Application
heap	I-Application
operations	O
using	O
the	O
potential	B-General_Concept
method	I-General_Concept
for	O
amortized	B-General_Concept
analysis	I-General_Concept
.	O
</s>
<s>
Using	O
this	O
potential	O
,	O
we	O
can	O
obtain	O
the	O
desired	O
amortized	B-General_Concept
running	O
times	O
:	O
</s>
<s>
Here	O
,	O
the	O
potential	O
is	O
unchanged	O
,	O
so	O
the	O
amortized	B-General_Concept
cost	O
of	O
creation	O
is	O
,	O
the	O
actual	O
cost	O
.	O
</s>
<s>
If	O
the	O
merge	O
is	O
employed	O
,	O
then	O
the	O
drop	O
in	O
the	O
potential	O
function	O
is	O
exactly	O
the	O
actual	O
cost	O
of	O
merging	O
and	O
,	O
so	O
the	O
amortized	B-General_Concept
cost	O
is	O
.	O
</s>
<s>
By	O
choice	O
of	O
the	O
threshold	O
function	O
,	O
we	O
thus	O
obtain	O
that	O
the	O
amortized	B-General_Concept
cost	O
of	O
insertion	O
is	O
:	O
</s>
<s>
By	O
choice	O
of	O
,	O
we	O
have	O
that	O
the	O
amortized	B-General_Concept
cost	O
of	O
this	O
operation	O
is	O
the	O
same	O
as	O
the	O
actual	O
cost	O
.	O
</s>
<s>
A	O
naive	O
binary	B-Application
heap	I-Application
merging	O
algorithm	O
will	O
merge	O
the	O
two	O
heaps	O
and	O
in	O
time	O
by	O
simply	O
concatenating	O
both	O
heaps	O
and	O
making	O
a	O
heap	O
out	O
of	O
the	O
resulting	O
array	B-Data_Structure
using	O
Floyd	O
's	O
algorithm	O
for	O
heap	O
construction	O
.	O
</s>
<s>
Sack	O
and	O
Strothotte	O
proposed	O
an	O
algorithm	O
for	O
merging	O
the	O
binary	B-Application
heaps	I-Application
in	O
time	O
.	O
</s>
<s>
For	O
instance	O
,	O
Fibonacci	B-Application
heaps	I-Application
can	O
be	O
merged	O
in	O
time	O
.	O
</s>
<s>
Since	O
binary	B-Application
heaps	I-Application
require	O
time	O
to	O
merge	O
,	O
shadow	O
merge	O
remains	O
efficient	O
.	O
</s>
