<s>
A	O
bucket	B-Application
queue	I-Application
is	O
a	O
data	B-General_Concept
structure	I-General_Concept
that	O
implements	O
the	O
priority	B-Application
queue	I-Application
abstract	O
data	O
type	O
:	O
it	O
maintains	O
a	O
dynamic	O
collection	O
of	O
elements	O
with	O
numerical	O
priorities	O
and	O
allows	O
quick	O
access	O
to	O
the	O
element	O
with	O
minimum	O
(	O
or	O
maximum	O
)	O
priority	O
.	O
</s>
<s>
In	O
the	O
bucket	B-Application
queue	I-Application
,	O
the	O
priorities	O
must	O
be	O
integers	O
,	O
and	O
it	O
is	O
particularly	O
suited	O
to	O
applications	O
in	O
which	O
the	O
priorities	O
have	O
a	O
small	O
range	O
.	O
</s>
<s>
A	O
bucket	B-Application
queue	I-Application
has	O
the	O
form	O
of	O
an	O
array	O
of	O
buckets	O
:	O
an	O
array	B-Data_Structure
data	I-Data_Structure
structure	I-Data_Structure
,	O
indexed	O
by	O
the	O
priorities	O
,	O
whose	O
cells	O
contain	O
collections	B-Application
of	I-Application
items	I-Application
with	O
the	O
same	O
priority	O
as	O
each	O
other	O
.	O
</s>
<s>
With	O
this	O
data	B-General_Concept
structure	I-General_Concept
,	O
insertion	O
of	O
elements	O
and	O
changes	O
of	O
their	O
priority	O
take	O
constant	O
time	O
.	O
</s>
<s>
The	O
bucket	B-Application
queue	I-Application
is	O
the	O
priority-queue	O
analogue	O
of	O
pigeonhole	B-Algorithm
sort	I-Algorithm
(	O
also	O
called	O
bucket	O
sort	O
)	O
,	O
a	O
sorting	O
algorithm	O
that	O
places	O
elements	O
into	O
buckets	O
indexed	O
by	O
their	O
priorities	O
and	O
then	O
concatenates	O
the	O
buckets	O
.	O
</s>
<s>
Using	O
a	O
bucket	B-Application
queue	I-Application
as	O
the	O
priority	B-Application
queue	I-Application
in	O
a	O
selection	B-Algorithm
sort	I-Algorithm
gives	O
a	O
form	O
of	O
the	O
pigeonhole	B-Algorithm
sort	I-Algorithm
algorithm	O
.	O
</s>
<s>
Bucket	B-Application
queues	I-Application
are	O
also	O
called	O
bucket	O
priority	B-Application
queues	I-Application
or	O
bounded-height	O
priority	B-Application
queues	I-Application
.	O
</s>
<s>
When	O
used	O
for	O
quantized	O
approximations	O
to	O
real	O
number	O
priorities	O
,	O
they	O
are	O
also	O
called	O
untidy	O
priority	B-Application
queues	I-Application
or	O
pseudo	O
priority	B-Application
queues	I-Application
.	O
</s>
<s>
They	O
are	O
closely	O
related	O
to	O
the	O
calendar	B-Application
queue	I-Application
,	O
a	O
structure	O
that	O
uses	O
a	O
similar	O
array	O
of	O
buckets	O
for	O
exact	O
prioritization	O
by	O
real	O
numbers	O
.	O
</s>
<s>
Applications	O
of	O
the	O
bucket	B-Application
queue	I-Application
include	O
computation	O
of	O
the	O
degeneracy	B-Algorithm
of	I-Algorithm
a	I-Algorithm
graph	I-Algorithm
,	O
fast	O
algorithms	O
for	O
shortest	O
paths	O
and	O
widest	O
paths	O
for	O
graphs	O
with	O
weights	O
that	O
are	O
small	O
integers	O
or	O
are	O
already	O
sorted	O
,	O
and	O
greedy	O
approximation	B-Algorithm
algorithms	I-Algorithm
for	O
the	O
set	B-Algorithm
cover	I-Algorithm
problem	I-Algorithm
.	O
</s>
<s>
The	O
quantized	O
version	O
of	O
the	O
structure	O
has	O
also	O
been	O
applied	O
to	O
scheduling	O
and	O
to	O
marching	B-Algorithm
cubes	I-Algorithm
in	O
computer	O
graphics	O
.	O
</s>
<s>
The	O
first	O
use	O
of	O
the	O
bucket	B-Application
queue	I-Application
was	O
in	O
a	O
shortest	O
path	O
algorithm	O
by	O
.	O
</s>
<s>
A	O
bucket	B-Application
queue	I-Application
can	O
handle	O
elements	O
with	O
integer	O
priorities	O
in	O
the	O
range	O
from	O
0	O
or	O
1	O
up	O
to	O
some	O
known	O
bound	O
,	O
and	O
operations	O
that	O
insert	O
elements	O
,	O
change	O
the	O
priority	O
of	O
elements	O
,	O
or	O
extract	O
(	O
find	O
and	O
remove	O
)	O
the	O
element	O
that	O
has	O
the	O
minimum	O
(	O
or	O
maximum	O
)	O
priority	O
.	O
</s>
<s>
It	O
consists	O
of	O
an	O
array	O
of	O
container	B-Application
data	I-Application
structures	I-Application
;	O
in	O
most	O
sources	O
these	O
containers	B-Application
are	O
doubly	B-Data_Structure
linked	I-Data_Structure
lists	I-Data_Structure
but	O
they	O
could	O
alternatively	O
be	O
dynamic	B-Data_Structure
arrays	I-Data_Structure
or	O
dynamic	O
sets	O
.	O
</s>
<s>
A	O
bucket	B-Application
queue	I-Application
can	O
handle	O
the	O
following	O
operations	O
:	O
</s>
<s>
To	O
insert	O
an	O
element	O
with	O
priority	O
,	O
add	O
to	O
the	O
container	B-Application
at	O
.	O
</s>
<s>
To	O
change	O
the	O
priority	O
of	O
an	O
element	O
,	O
remove	O
it	O
from	O
the	O
container	B-Application
for	O
its	O
old	O
priority	O
and	O
re-insert	O
it	O
into	O
the	O
container	B-Application
for	O
its	O
new	O
priority	O
.	O
</s>
<s>
To	O
extract	O
an	O
element	O
with	O
the	O
minimum	O
or	O
maximum	O
priority	O
,	O
perform	O
a	O
sequential	B-Algorithm
search	I-Algorithm
in	O
the	O
array	O
to	O
find	O
the	O
first	O
or	O
last	O
non-empty	O
container	B-Application
,	O
respectively	O
,	O
choose	O
an	O
arbitrary	O
element	O
from	O
this	O
container	B-Application
,	O
and	O
remove	O
it	O
from	O
the	O
container	B-Application
.	O
</s>
<s>
As	O
an	O
optimization	O
,	O
the	O
data	B-General_Concept
structure	I-General_Concept
can	O
start	O
each	O
sequential	B-Algorithm
search	I-Algorithm
for	O
a	O
non-empty	O
bucket	O
at	O
the	O
most	O
recently-found	O
non-empty	O
bucket	O
instead	O
of	O
at	O
the	O
start	O
of	O
the	O
array	O
.	O
</s>
<s>
This	O
can	O
be	O
done	O
in	O
either	O
of	O
two	O
different	O
ways	O
,	O
lazy	O
(	O
delaying	O
these	O
sequential	B-Algorithm
searches	I-Algorithm
until	O
they	O
are	O
necessary	O
)	O
or	O
eager	O
(	O
doing	O
the	O
searches	O
ahead	O
of	O
time	O
)	O
.	O
</s>
<s>
The	O
choice	O
of	O
when	O
to	O
do	O
the	O
search	O
affects	O
which	O
of	O
the	O
data	B-General_Concept
structure	I-General_Concept
operations	O
is	O
slowed	O
by	O
these	O
searches	O
.	O
</s>
<s>
When	O
inserting	O
a	O
new	O
element	O
with	O
a	O
priority	O
smaller	O
than	O
,	O
the	O
data	B-General_Concept
structure	I-General_Concept
sets	O
to	O
the	O
new	O
priority	O
,	O
and	O
when	O
removing	O
the	O
last	O
element	O
from	O
a	O
bucket	O
with	O
priority	O
,	O
it	O
performs	O
a	O
sequential	B-Algorithm
search	I-Algorithm
through	O
larger	O
indexes	O
until	O
finding	O
a	O
non-empty	O
bucket	O
and	O
setting	O
to	O
the	O
priority	O
of	O
the	O
resulting	O
bucket	O
.	O
</s>
<s>
In	O
either	O
of	O
these	O
two	O
variations	O
,	O
each	O
sequential	B-Algorithm
search	I-Algorithm
takes	O
time	O
proportional	O
to	O
the	O
difference	O
between	O
the	O
old	O
and	O
new	O
values	O
of	O
.	O
</s>
<s>
This	O
could	O
be	O
significantly	O
faster	O
than	O
the	O
time	O
bound	O
for	O
the	O
searches	O
in	O
the	O
un-optimized	O
version	O
of	O
the	O
data	B-General_Concept
structure	I-General_Concept
.	O
</s>
<s>
In	O
many	O
applications	O
of	O
priority	B-Application
queues	I-Application
such	O
as	O
Dijkstra	B-Algorithm
's	I-Algorithm
algorithm	I-Algorithm
,	O
the	O
minimum	O
priorities	O
form	O
a	O
monotonic	O
sequence	O
,	O
allowing	O
a	O
monotone	B-Application
priority	I-Application
queue	I-Application
to	O
be	O
used	O
.	O
</s>
<s>
In	O
these	O
applications	O
,	O
for	O
both	O
the	O
lazy	O
and	O
eager	O
variations	O
of	O
the	O
optimized	O
structure	O
,	O
the	O
sequential	B-Algorithm
searches	I-Algorithm
for	O
non-empty	O
buckets	O
cover	O
disjoint	O
ranges	O
of	O
buckets	O
.	O
</s>
<s>
A	O
corresponding	O
optimization	O
can	O
be	O
applied	O
in	O
applications	O
where	O
a	O
bucket	B-Application
queue	I-Application
is	O
used	O
to	O
find	O
elements	O
of	O
maximum	O
priority	O
,	O
but	O
in	O
this	O
case	O
it	O
should	O
maintain	O
an	O
index	O
that	O
upper-bounds	O
the	O
maximum	O
priority	O
,	O
and	O
the	O
sequential	B-Algorithm
search	I-Algorithm
for	O
a	O
non-empty	O
bucket	O
should	O
proceed	O
downwards	O
from	O
this	O
upper	O
bound	O
.	O
</s>
<s>
In	O
particular	O
,	O
this	O
idea	O
can	O
be	O
applied	O
in	O
Dijkstra	B-Algorithm
's	I-Algorithm
algorithm	I-Algorithm
on	O
graphs	O
whose	O
edge	O
lengths	O
are	O
integers	O
in	O
the	O
range	O
from	O
1	O
to	O
.	O
</s>
<s>
Because	O
creating	O
a	O
new	O
bucket	B-Application
queue	I-Application
involves	O
initializing	O
an	O
array	O
of	O
empty	O
buckets	O
,	O
this	O
initialization	O
step	O
takes	O
time	O
proportional	O
to	O
the	O
number	O
of	O
priorities	O
.	O
</s>
<s>
A	O
variation	O
of	O
the	O
bucket	B-Application
queue	I-Application
described	O
by	O
Donald	O
B	O
.	O
Johnson	O
in	O
1981	O
instead	O
stores	O
only	O
the	O
non-empty	O
buckets	O
in	O
a	O
linked	O
list	O
,	O
sorted	O
by	O
their	O
priorities	O
,	O
and	O
uses	O
an	O
auxiliary	O
search	O
tree	O
to	O
quickly	O
find	O
the	O
position	O
in	O
this	O
linked	O
list	O
for	O
any	O
new	O
buckets	O
.	O
</s>
<s>
For	O
example	O
,	O
consider	O
a	O
bucket	B-Application
queue	I-Application
with	O
four	O
priorities	O
,	O
the	O
numbers	O
0	O
,	O
1	O
,	O
2	O
,	O
and	O
3	O
.	O
</s>
<s>
Extracting	O
the	O
minimum-priority	O
element	O
,	O
in	O
the	O
basic	O
version	O
of	O
the	O
bucket	B-Application
queue	I-Application
,	O
searches	O
from	O
the	O
start	O
of	O
to	O
find	O
its	O
first	O
non-empty	O
element	O
:	O
is	O
empty	O
but	O
,	O
a	O
non-empty	O
set	O
.	O
</s>
<s>
The	O
second	O
extract	O
operation	O
,	O
in	O
the	O
basic	O
version	O
of	O
the	O
bucket	B-Application
queue	I-Application
,	O
searches	O
again	O
from	O
the	O
start	O
of	O
the	O
array	O
:	O
,	O
,	O
,	O
non-empty	O
.	O
</s>
<s>
In	O
the	O
improved	O
variants	O
of	O
the	O
bucket	B-Application
queue	I-Application
,	O
this	O
search	O
starts	O
instead	O
at	O
the	O
last	O
position	O
that	O
was	O
found	O
to	O
be	O
non-empty	O
,	O
.	O
</s>
<s>
A	O
bucket	B-Application
queue	I-Application
can	O
be	O
used	O
to	O
maintain	O
the	O
vertices	O
of	O
an	O
undirected	O
graph	O
,	O
prioritized	O
by	O
their	O
degrees	O
,	O
and	O
repeatedly	O
find	O
and	O
remove	O
the	O
vertex	O
of	O
minimum	O
degree	O
.	O
</s>
<s>
This	O
greedy	B-Algorithm
algorithm	I-Algorithm
can	O
be	O
used	O
to	O
calculate	O
the	O
degeneracy	B-Algorithm
of	O
a	O
given	O
graph	O
,	O
equal	O
to	O
the	O
largest	O
degree	O
of	O
any	O
vertex	O
at	O
the	O
time	O
of	O
its	O
removal	O
.	O
</s>
<s>
In	O
Dijkstra	B-Algorithm
's	I-Algorithm
algorithm	I-Algorithm
for	O
shortest	O
paths	O
in	O
directed	O
graphs	O
with	O
edge	O
weights	O
that	O
are	O
positive	O
integers	O
,	O
the	O
priorities	O
are	O
monotone	O
,	O
and	O
a	O
monotone	O
bucket	B-Application
queue	I-Application
can	O
be	O
used	O
to	O
obtain	O
a	O
time	O
bound	O
of	O
,	O
where	O
is	O
the	O
number	O
of	O
edges	O
,	O
is	O
the	O
diameter	O
of	O
the	O
network	O
,	O
and	O
is	O
the	O
maximum	O
(	O
integer	O
)	O
link	O
cost	O
.	O
</s>
<s>
This	O
variant	O
of	O
Dijkstra	B-Algorithm
's	I-Algorithm
algorithm	I-Algorithm
is	O
also	O
known	O
as	O
Dial	O
's	O
algorithm	O
,	O
after	O
Robert	O
B	O
.	O
</s>
<s>
The	O
same	O
idea	O
also	O
works	O
,	O
using	O
a	O
quantized	O
bucket	B-Application
queue	I-Application
,	O
for	O
graphs	O
with	O
positive	O
real	O
edge	O
weights	O
when	O
the	O
ratio	O
of	O
the	O
maximum	O
to	O
minimum	O
weight	O
is	O
at	O
most	O
.	O
</s>
<s>
In	O
this	O
quantized	O
version	O
of	O
the	O
algorithm	O
,	O
the	O
vertices	O
are	O
processed	O
out	O
of	O
order	O
,	O
compared	O
to	O
the	O
result	O
with	O
a	O
non-quantized	O
priority	B-Application
queue	I-Application
,	O
but	O
the	O
correct	O
shortest	O
paths	O
are	O
still	O
found	O
.	O
</s>
<s>
The	O
set	B-Algorithm
cover	I-Algorithm
problem	I-Algorithm
has	O
as	O
its	O
input	O
a	O
family	O
of	O
sets	O
.	O
</s>
<s>
It	O
is	O
NP-hard	O
,	O
but	O
has	O
a	O
greedy	O
approximation	B-Algorithm
algorithm	I-Algorithm
that	O
achieves	O
a	O
logarithmic	O
approximation	B-Algorithm
ratio	I-Algorithm
,	O
essentially	O
the	O
best	O
possible	O
unless	O
P	O
=	O
NP	O
.	O
</s>
<s>
This	O
approximation	B-Algorithm
algorithm	I-Algorithm
selects	O
its	O
subfamily	O
by	O
repeatedly	O
choosing	O
a	O
set	O
that	O
covers	O
the	O
maximum	O
possible	O
number	O
of	O
remaining	O
uncovered	O
elements	O
.	O
</s>
<s>
This	O
may	O
be	O
solved	O
using	O
a	O
bucket	B-Application
queue	I-Application
of	O
sets	O
in	O
the	O
input	O
family	O
,	O
prioritized	O
by	O
the	O
number	O
of	O
remaining	O
elements	O
that	O
they	O
cover	O
.	O
</s>
<s>
Each	O
time	O
that	O
the	O
greedy	B-Algorithm
algorithm	I-Algorithm
chooses	O
a	O
set	O
as	O
part	O
of	O
its	O
output	O
,	O
the	O
newly	O
covered	O
set	O
elements	O
should	O
be	O
subtracted	O
from	O
the	O
priorities	O
of	O
the	O
other	O
sets	O
that	O
cover	O
them	O
;	O
over	O
the	O
course	O
of	O
the	O
algorithm	O
the	O
number	O
of	O
these	O
changes	O
of	O
priorities	O
is	O
just	O
the	O
sum	O
of	O
sizes	O
of	O
the	O
input	O
sets	O
.	O
</s>
<s>
Each	O
choice	O
of	O
the	O
greedy	B-Algorithm
algorithm	I-Algorithm
involves	O
finding	O
the	O
set	O
with	O
the	O
maximum	O
priority	O
,	O
which	O
can	O
be	O
done	O
by	O
scanning	O
downwards	O
through	O
the	O
buckets	O
of	O
the	O
bucket	B-Application
queue	I-Application
,	O
starting	O
from	O
the	O
most	O
recent	O
previous	O
maximum	O
value	O
.	O
</s>
<s>
Bucket	B-Application
queues	I-Application
can	O
be	O
used	O
to	O
schedule	O
tasks	O
with	O
deadlines	O
,	O
for	O
instance	O
in	O
packet	B-Protocol
forwarding	I-Protocol
for	O
internet	O
data	O
with	O
quality	O
of	O
service	O
guarantees	O
.	O
</s>
<s>
A	O
variation	O
of	O
the	O
quantized	O
bucket	B-Application
queue	I-Application
data	B-General_Concept
structure	I-General_Concept
,	O
the	O
calendar	B-Application
queue	I-Application
,	O
has	O
been	O
applied	O
to	O
scheduling	O
of	O
discrete-event	B-General_Concept
simulations	I-General_Concept
,	O
where	O
the	O
elements	O
in	O
the	O
queue	O
are	O
future	O
events	O
prioritized	O
by	O
the	O
time	O
within	O
the	O
simulation	O
that	O
the	O
events	O
should	O
happen	O
.	O
</s>
<s>
Therefore	O
,	O
the	O
calendar	B-Application
queue	I-Application
performs	O
searches	O
for	O
the	O
minimum-priority	O
element	O
in	O
a	O
different	O
way	O
than	O
a	O
bucket	B-Application
queue	I-Application
:	O
in	O
the	O
bucket	B-Application
queue	I-Application
,	O
any	O
element	O
of	O
the	O
first	O
non-empty	O
bucket	O
may	O
be	O
returned	O
,	O
but	O
instead	O
the	O
calendar	B-Application
queue	I-Application
searches	O
all	O
the	O
elements	O
in	O
that	O
bucket	O
to	O
determine	O
which	O
of	O
them	O
has	O
the	O
smallest	O
non-quantized	O
priority	O
.	O
</s>
<s>
To	O
keep	O
these	O
searches	O
fast	O
,	O
this	O
variation	O
attempts	O
to	O
keep	O
the	O
number	O
of	O
buckets	O
proportional	O
to	O
the	O
number	O
of	O
elements	O
,	O
by	O
adjusting	O
the	O
scale	O
of	O
quantization	O
and	O
rebuilding	O
the	O
data	B-General_Concept
structure	I-General_Concept
when	O
it	O
gets	O
out	O
of	O
balance	O
.	O
</s>
<s>
Calendar	B-Application
queues	I-Application
may	O
be	O
slower	O
than	O
bucket	B-Application
queues	I-Application
in	O
the	O
worst	O
case	O
(	O
when	O
many	O
elements	O
all	O
land	O
in	O
the	O
same	O
smallest	O
bucket	O
)	O
but	O
are	O
fast	O
when	O
elements	O
are	O
uniformly	O
distributed	O
among	O
buckets	O
causing	O
the	O
average	O
bucket	O
size	O
to	O
be	O
constant	O
.	O
</s>
<s>
In	O
applied	O
mathematics	O
and	O
numerical	B-Algorithm
methods	I-Algorithm
for	O
the	O
solution	O
of	O
differential	O
equations	O
,	O
untidy	O
priority	B-Application
queues	I-Application
have	O
been	O
used	O
to	O
prioritize	O
the	O
steps	O
of	O
the	O
fast	B-Algorithm
marching	I-Algorithm
method	I-Algorithm
for	O
solving	O
boundary	O
value	O
problems	O
of	O
the	O
Eikonal	O
equation	O
,	O
used	O
to	O
model	O
wave	O
propagation	O
.	O
</s>
<s>
This	O
method	O
finds	O
the	O
times	O
at	O
which	O
a	O
moving	O
boundary	O
crosses	O
a	O
set	O
of	O
discrete	O
points	O
(	O
such	O
as	O
the	O
points	O
of	O
an	O
integer	O
grid	O
)	O
using	O
a	O
prioritization	O
method	O
resembling	O
a	O
continuous	O
version	O
of	O
Dijkstra	B-Algorithm
's	I-Algorithm
algorithm	I-Algorithm
,	O
and	O
its	O
running	O
time	O
is	O
dominated	O
by	O
its	O
priority	B-Application
queue	I-Application
of	O
these	O
points	O
.	O
</s>
<s>
It	O
can	O
be	O
sped	O
up	O
to	O
linear	O
time	O
by	O
rounding	O
the	O
priorities	O
used	O
in	O
this	O
algorithm	O
to	O
integers	O
,	O
and	O
using	O
a	O
bucket	B-Application
queue	I-Application
for	O
these	O
integers	O
.	O
</s>
<s>
As	O
in	O
Dijkstra	O
's	O
and	O
Dial	O
's	O
algorithms	O
,	O
the	O
priorities	O
are	O
monototone	O
,	O
so	O
fast	B-Algorithm
marching	I-Algorithm
can	O
use	O
the	O
monotone	O
optimization	O
of	O
the	O
bucket	B-Application
queue	I-Application
and	O
its	O
analysis	O
.	O
</s>
