<s>
ProxmapSort	O
,	O
or	O
Proxmap	B-Algorithm
sort	I-Algorithm
,	O
is	O
a	O
sorting	B-Algorithm
algorithm	I-Algorithm
that	O
works	O
by	O
partitioning	O
an	O
array	B-Data_Structure
of	O
data	O
items	O
,	O
or	O
keys	O
,	O
into	O
a	O
number	O
of	O
"	O
subarrays	O
"	O
(	O
termed	O
buckets	O
,	O
in	O
similar	O
sorts	O
)	O
.	O
</s>
<s>
Keys	O
are	O
placed	O
into	O
each	O
subarray	O
using	O
insertion	B-Algorithm
sort	I-Algorithm
.	O
</s>
<s>
If	O
keys	O
are	O
"	O
well	O
distributed	O
"	O
among	O
the	O
subarrays	O
,	O
sorting	B-Algorithm
occurs	O
in	O
linear	O
time	O
.	O
</s>
<s>
The	O
computational	B-General_Concept
complexity	I-General_Concept
estimates	O
involve	O
the	O
number	O
of	O
subarrays	O
and	O
the	O
proximity	O
mapping	O
function	O
,	O
the	O
"	O
map	O
key	O
,	O
"	O
used	O
.	O
</s>
<s>
It	O
is	O
a	O
form	O
of	O
bucket	B-Algorithm
and	O
radix	B-Algorithm
sort	I-Algorithm
.	O
</s>
<s>
Once	O
a	O
ProxmapSort	O
is	O
complete	O
,	O
ProxmapSearch	O
can	O
be	O
used	O
to	O
find	O
keys	O
in	O
the	O
sorted	O
array	B-Data_Structure
in	O
time	O
if	O
the	O
keys	O
were	O
well	O
distributed	O
during	O
the	O
sort	O
.	O
</s>
<s>
Given	O
an	O
array	B-Data_Structure
A	O
with	O
n	O
keys	O
:	O
</s>
<s>
for	O
each	O
key	O
,	O
look	O
up	O
its	O
location	O
,	O
place	O
it	O
into	O
that	O
cell	O
of	O
A2	O
;	O
if	O
it	O
collides	O
with	O
a	O
key	O
already	O
in	O
that	O
position	O
,	O
insertion	B-Algorithm
sort	I-Algorithm
the	O
key	O
into	O
place	O
,	O
moving	O
keys	O
greater	O
than	O
this	O
key	O
to	O
the	O
right	O
by	O
one	O
to	O
make	O
a	O
space	O
for	O
this	O
key	O
.	O
</s>
<s>
Disperse	O
:	O
Read	O
over	O
A	O
,	O
dropping	O
each	O
key	O
into	O
its	O
bucket	B-Algorithm
in	O
A2	O
;	O
insertion	O
sorting	B-Algorithm
as	O
needed	O
.	O
</s>
<s>
Collect	O
:	O
Visit	O
the	O
subarrays	O
in	O
order	O
and	O
put	O
all	O
the	O
elements	O
back	O
into	O
the	O
original	O
array	B-Data_Structure
,	O
or	O
simply	O
use	O
A2	O
.	O
</s>
<s>
Note	O
:	O
"	O
keys	O
"	O
may	O
also	O
contain	O
other	O
data	O
,	O
for	O
instance	O
an	O
array	B-Data_Structure
of	O
Student	O
objects	O
that	O
contain	O
the	O
key	O
plus	O
a	O
student	O
ID	O
and	O
name	O
.	O
</s>
<s>
Consider	O
a	O
full	O
array	B-Data_Structure
:	O
A[ 0	O
to	O
n-1	O
]	O
with	O
n	O
keys	O
.	O
</s>
<s>
Sort	O
A	O
's	O
keys	O
into	O
array	B-Data_Structure
A2	O
of	O
equal	O
size	O
.	O
</s>
<s>
Here	O
A	O
is	O
the	O
array	B-Data_Structure
to	O
be	O
sorted	O
and	O
the	O
mapKey	O
functions	O
determines	O
the	O
number	O
of	O
subarrays	O
to	O
use	O
.	O
</s>
<s>
Dividing	O
the	O
key	O
by	O
a	O
constant	O
reduces	O
the	O
number	O
of	O
subarrays	O
;	O
different	O
functions	O
can	O
be	O
used	O
to	O
translate	O
the	O
range	O
of	O
elements	O
in	O
A	O
to	O
subarrays	O
,	O
such	O
as	O
converting	O
the	O
letters	O
A	O
–	O
Z	O
to	O
0	O
–	O
25	O
or	O
returning	O
the	O
first	O
character	O
(	O
0	O
–	O
255	O
)	O
for	O
sorting	B-Algorithm
strings	O
.	O
</s>
<s>
Subarrays	O
are	O
sorted	O
as	O
the	O
data	O
comes	O
in	O
,	O
not	O
after	O
all	O
data	O
has	O
been	O
placed	O
into	O
the	O
subarray	O
,	O
as	O
is	O
typical	O
in	O
bucket	B-Algorithm
sorting	I-Algorithm
.	O
</s>
<s>
ProxmapSearch	O
uses	O
the	O
proxMap	O
array	B-Data_Structure
generated	O
by	O
a	O
previously	O
done	O
ProxmapSort	O
to	O
find	O
keys	O
in	O
the	O
sorted	O
array	B-Data_Structure
A2	O
in	O
constant	O
time	O
.	O
</s>
<s>
Each	O
is	O
computed	O
with	O
one	O
pass	O
through	O
an	O
array	B-Data_Structure
,	O
with	O
constant	O
time	O
spent	O
at	O
each	O
array	B-Data_Structure
location	O
.	O
</s>
<s>
Worst	O
case	O
:	O
MapKey	O
places	O
all	O
items	O
into	O
one	O
subarray	O
,	O
resulting	O
in	O
a	O
standard	O
insertion	B-Algorithm
sort	I-Algorithm
,	O
and	O
time	O
of	O
.	O
</s>
<s>
Best	O
case	O
:	O
MapKey	O
delivers	O
the	O
same	O
small	O
number	O
of	O
items	O
to	O
each	O
subarray	O
in	O
an	O
order	O
where	O
the	O
best	O
case	O
of	O
insertion	B-Algorithm
sort	I-Algorithm
occurs	O
.	O
</s>
<s>
Each	O
insertion	B-Algorithm
sort	I-Algorithm
is	O
,	O
c	O
the	O
size	O
of	O
the	O
subarrays	O
;	O
there	O
are	O
p	O
subarrays	O
thus	O
p	O
*	O
c	O
=	O
n	O
,	O
so	O
the	O
insertion	O
phase	O
take	O
O(n )	O
;	O
thus	O
,	O
ProxmapSort	O
is	O
.	O
</s>
<s>
Average	O
case	O
:	O
Each	O
subarray	O
is	O
at	O
most	O
size	O
c	O
,	O
a	O
constant	O
;	O
insertion	B-Algorithm
sort	I-Algorithm
for	O
each	O
subarray	O
is	O
then	O
O( c^2	O
)	O
at	O
worst	O
–	O
a	O
constant	O
.	O
</s>
<s>
(	O
The	O
actual	O
time	O
can	O
be	O
much	O
better	O
,	O
since	O
c	O
items	O
are	O
not	O
sorted	O
until	O
the	O
last	O
item	O
is	O
placed	O
in	O
the	O
bucket	B-Algorithm
)	O
.	O
</s>
<s>
Save	O
space	O
:	O
The	O
proxMaps	O
can	O
be	O
stored	O
in	O
the	O
hitCount	O
array	B-Data_Structure
,	O
as	O
the	O
hit	O
counts	O
are	O
not	O
needed	O
once	O
the	O
proxmap	O
is	O
computed	O
;	O
the	O
data	O
can	O
be	O
sorted	O
back	O
into	O
A	O
,	O
instead	O
of	O
using	O
A2	O
,	O
if	O
one	O
takes	O
care	O
to	O
note	O
which	O
A	O
values	O
have	O
been	O
sorted	O
so	O
far	O
,	O
and	O
which	O
not	O
.	O
</s>
<s>
Since	O
ProxmapSort	O
is	O
not	O
a	O
comparison	B-Algorithm
sort	I-Algorithm
,	O
the	O
Ω(n log n )	O
lower	O
bound	O
is	O
inapplicable	O
.	O
</s>
<s>
Its	O
speed	O
can	O
be	O
attributed	O
to	O
it	O
not	O
being	O
comparison-based	O
and	O
using	O
arrays	O
instead	O
of	O
dynamically	O
allocated	O
objects	O
and	O
pointers	O
that	O
must	O
be	O
followed	O
,	O
such	O
as	O
is	O
done	O
with	O
when	O
using	O
a	O
binary	B-Language
search	I-Language
tree	I-Language
.	O
</s>
<s>
Like	O
ProxmapSort	O
,	O
bucket	B-Algorithm
sort	I-Algorithm
generally	O
operates	O
on	O
a	O
list	O
of	O
n	O
numeric	O
inputs	O
between	O
zero	O
and	O
some	O
maximum	O
key	O
or	O
value	O
M	O
and	O
divides	O
the	O
value	O
range	O
into	O
n	O
buckets	O
each	O
of	O
size	O
M/n	O
.	O
</s>
<s>
If	O
each	O
bucket	B-Algorithm
is	O
sorted	O
using	O
insertion	B-Algorithm
sort	I-Algorithm
,	O
ProxmapSort	O
and	O
bucket	B-Algorithm
sort	I-Algorithm
can	O
be	O
shown	O
to	O
run	O
in	O
predicted	O
linear	O
time	O
.	O
</s>
<s>
However	O
,	O
the	O
performance	O
of	O
this	O
sort	O
degrades	O
with	O
clustering	O
(	O
or	O
too	O
few	O
buckets	O
with	O
too	O
many	O
keys	O
)	O
;	O
if	O
many	O
values	O
occur	O
close	O
together	O
,	O
they	O
will	O
all	O
fall	O
into	O
a	O
single	O
bucket	B-Algorithm
and	O
performance	O
will	O
be	O
severely	O
diminished	O
.	O
</s>
