<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
a	O
perfect	B-Algorithm
hash	I-Algorithm
function	I-Algorithm
for	O
a	O
set	O
is	O
a	O
hash	B-Error_Name
function	I-Error_Name
that	O
maps	O
distinct	O
elements	O
in	O
to	O
a	O
set	O
of	O
integers	O
,	O
with	O
no	O
collisions	B-Algorithm
.	O
</s>
<s>
Perfect	B-Algorithm
hash	I-Algorithm
functions	I-Algorithm
may	O
be	O
used	O
to	O
implement	O
a	O
lookup	B-Data_Structure
table	I-Data_Structure
with	O
constant	O
worst-case	O
access	O
time	O
.	O
</s>
<s>
A	O
perfect	B-Algorithm
hash	I-Algorithm
function	I-Algorithm
can	O
,	O
as	O
any	O
hash	B-Error_Name
function	I-Error_Name
,	O
be	O
used	O
to	O
implement	O
hash	B-Algorithm
tables	I-Algorithm
,	O
with	O
the	O
advantage	O
that	O
no	O
collision	O
resolution	O
has	O
to	O
be	O
implemented	O
.	O
</s>
<s>
In	O
addition	O
,	O
if	O
the	O
keys	O
are	O
not	O
the	O
data	O
and	O
if	O
it	O
is	O
known	O
that	O
queried	O
keys	O
will	O
be	O
valid	O
,	O
then	O
the	O
keys	O
do	O
not	O
need	O
to	O
be	O
stored	O
in	O
the	O
lookup	B-Data_Structure
table	I-Data_Structure
,	O
saving	O
space	O
.	O
</s>
<s>
Disadvantages	O
of	O
perfect	B-Algorithm
hash	I-Algorithm
functions	I-Algorithm
are	O
that	O
needs	O
to	O
be	O
known	O
for	O
the	O
construction	O
of	O
the	O
perfect	B-Algorithm
hash	I-Algorithm
function	I-Algorithm
.	O
</s>
<s>
For	O
frequently	O
changing	O
dynamic	B-Algorithm
perfect	I-Algorithm
hash	I-Algorithm
functions	I-Algorithm
may	O
be	O
used	O
at	O
the	O
cost	O
of	O
additional	O
space	O
.	O
</s>
<s>
The	O
space	O
requirement	O
to	O
store	O
the	O
perfect	B-Algorithm
hash	I-Algorithm
function	I-Algorithm
is	O
in	O
.	O
</s>
<s>
The	O
important	O
performance	O
parameters	O
for	O
perfect	B-Algorithm
hash	I-Algorithm
functions	I-Algorithm
are	O
the	O
evaluation	O
time	O
,	O
which	O
should	O
be	O
constant	O
,	O
the	O
construction	O
time	O
,	O
and	O
the	O
representation	O
size	O
.	O
</s>
<s>
A	O
perfect	B-Algorithm
hash	I-Algorithm
function	I-Algorithm
with	O
values	O
in	O
a	O
limited	O
range	O
can	O
be	O
used	O
for	O
efficient	O
lookup	B-Data_Structure
operations	O
,	O
by	O
placing	O
keys	O
from	O
(	O
or	O
other	O
associated	O
values	O
)	O
in	O
a	O
lookup	B-Data_Structure
table	I-Data_Structure
indexed	O
by	O
the	O
output	O
of	O
the	O
function	O
.	O
</s>
<s>
Each	O
such	O
lookup	B-Data_Structure
takes	O
constant	O
time	O
in	O
the	O
worst	B-General_Concept
case	I-General_Concept
.	O
</s>
<s>
With	O
perfect	B-Algorithm
hashing	I-Algorithm
,	O
the	O
associated	O
data	O
can	O
be	O
read	O
or	O
written	O
with	O
a	O
single	O
access	O
to	O
the	O
table	O
.	O
</s>
<s>
The	O
important	O
performance	O
parameters	O
for	O
perfect	B-Algorithm
hashing	I-Algorithm
are	O
the	O
representation	O
size	O
,	O
the	O
evaluation	O
time	O
,	O
the	O
construction	O
time	O
,	O
and	O
additionally	O
the	O
range	O
requirement	O
.	O
</s>
<s>
Let	O
and	O
a	O
perfect	B-Algorithm
hash	I-Algorithm
function	I-Algorithm
.	O
</s>
<s>
For	O
minimal	B-Algorithm
perfect	I-Algorithm
hashing	I-Algorithm
,	O
,	O
the	O
lower	O
bound	O
is	O
bits	O
per	O
element	O
.	O
</s>
<s>
A	O
perfect	B-Algorithm
hash	I-Algorithm
function	I-Algorithm
for	O
a	O
specific	O
set	O
that	O
can	O
be	O
evaluated	O
in	O
constant	O
time	O
,	O
and	O
with	O
values	O
in	O
a	O
small	O
range	O
,	O
can	O
be	O
found	O
by	O
a	O
randomized	B-General_Concept
algorithm	I-General_Concept
in	O
a	O
number	O
of	O
operations	O
that	O
is	O
proportional	O
to	O
the	O
size	O
of	O
S	O
.	O
</s>
<s>
The	O
original	O
construction	O
of	O
uses	O
a	O
two-level	O
scheme	O
to	O
map	O
a	O
set	O
of	O
elements	O
to	O
a	O
range	O
of	O
indices	O
,	O
and	O
then	O
map	O
each	O
index	O
to	O
a	O
range	O
of	O
hash	B-Error_Name
values	I-Error_Name
.	O
</s>
<s>
If	O
is	O
chosen	O
randomly	O
,	O
this	O
step	O
is	O
likely	O
to	O
have	O
collisions	B-Algorithm
,	O
but	O
the	O
number	O
of	O
elements	O
that	O
are	O
simultaneously	O
mapped	O
to	O
the	O
same	O
index	O
is	O
likely	O
to	O
be	O
small	O
.	O
</s>
<s>
The	O
hash	B-Error_Name
function	I-Error_Name
itself	O
requires	O
storage	O
space	O
to	O
store	O
,	O
,	O
and	O
all	O
of	O
the	O
second-level	O
linear	O
modular	O
functions	O
.	O
</s>
<s>
Computing	O
the	O
hash	B-Error_Name
value	I-Error_Name
of	O
a	O
given	O
key	O
may	O
be	O
performed	O
in	O
constant	O
time	O
by	O
computing	O
,	O
looking	O
up	O
the	O
second-level	O
function	O
associated	O
with	O
,	O
and	O
applying	O
this	O
function	O
to	O
.	O
</s>
<s>
A	O
modified	O
version	O
of	O
this	O
two-level	O
scheme	O
with	O
a	O
larger	O
number	O
of	O
values	O
at	O
the	O
top	O
level	O
can	O
be	O
used	O
to	O
construct	O
a	O
perfect	B-Algorithm
hash	I-Algorithm
function	I-Algorithm
that	O
maps	O
into	O
a	O
smaller	O
range	O
of	O
length	O
.	O
</s>
<s>
A	O
more	O
recent	O
method	O
for	O
constructing	O
a	O
perfect	B-Algorithm
hash	I-Algorithm
function	I-Algorithm
is	O
described	O
by	O
as	O
"	O
hash	B-Error_Name
,	O
displace	O
,	O
and	O
compress	O
"	O
.	O
</s>
<s>
Here	O
a	O
first-level	O
hash	B-Error_Name
function	I-Error_Name
is	O
also	O
used	O
to	O
map	O
elements	O
onto	O
a	O
range	O
of	O
integers	O
.	O
</s>
<s>
Then	O
,	O
in	O
descending	O
order	O
of	O
size	O
,	O
each	O
bucket	O
's	O
elements	O
are	O
hashed	O
by	O
a	O
hash	B-Error_Name
function	I-Error_Name
of	O
a	O
sequence	O
of	O
independent	O
fully	O
random	O
hash	B-Error_Name
functions	I-Error_Name
,	O
starting	O
with	O
.	O
</s>
<s>
If	O
the	O
hash	B-Error_Name
function	I-Error_Name
does	O
not	O
produce	O
any	O
collisions	B-Algorithm
for	O
the	O
bucket	O
,	O
and	O
the	O
resulting	O
values	O
are	O
not	O
yet	O
occupied	O
by	O
other	O
elements	O
from	O
other	O
buckets	O
,	O
the	O
function	O
is	O
chosen	O
for	O
that	O
bucket	O
.	O
</s>
<s>
If	O
not	O
,	O
the	O
next	O
hash	B-Error_Name
function	I-Error_Name
in	O
the	O
sequence	O
is	O
tested	O
.	O
</s>
<s>
To	O
evaluate	O
the	O
perfect	B-Algorithm
hash	I-Algorithm
function	I-Algorithm
one	O
only	O
has	O
to	O
save	O
the	O
mapping	O
σ	O
of	O
the	O
bucket	O
index	O
onto	O
the	O
correct	O
hash	B-Error_Name
function	I-Error_Name
in	O
the	O
sequence	O
,	O
resulting	O
in	O
.	O
</s>
<s>
For	O
perfect	B-Algorithm
hash	I-Algorithm
functions	I-Algorithm
,	O
it	O
is	O
first	O
assumed	O
that	O
the	O
range	O
of	O
is	O
bounded	O
by	O
as	O
.	O
</s>
<s>
A	O
trivial	O
but	O
pervasive	O
example	O
of	O
perfect	B-Algorithm
hashing	I-Algorithm
is	O
implicit	O
in	O
the	O
(	O
virtual	O
)	O
memory	B-Architecture
address	I-Architecture
space	I-Architecture
of	O
a	O
computer	O
.	O
</s>
<s>
Since	O
each	O
byte	O
of	O
virtual	B-Architecture
memory	I-Architecture
is	O
a	O
distinct	O
,	O
unique	O
,	O
directly	O
addressable	O
storage	O
location	O
,	O
the	O
value	O
of	O
the	O
(	O
starting	O
)	O
address	O
of	O
any	O
object	O
stored	O
in	O
memory	O
can	O
be	O
considered	O
a	O
de	O
facto	O
perfect	B-Algorithm
hash	I-Algorithm
of	O
that	O
object	O
into	O
the	O
entire	O
memory	O
address	O
range	O
.	O
</s>
<s>
Using	O
a	O
perfect	B-Algorithm
hash	I-Algorithm
function	I-Algorithm
is	O
best	O
in	O
situations	O
where	O
there	O
is	O
a	O
frequently	O
queried	O
large	O
set	O
,	O
,	O
which	O
is	O
seldom	O
updated	O
.	O
</s>
<s>
This	O
is	O
because	O
any	O
modification	O
of	O
the	O
set	O
may	O
cause	O
the	O
hash	B-Error_Name
function	I-Error_Name
to	O
no	O
longer	O
be	O
perfect	O
for	O
the	O
modified	O
set	O
.	O
</s>
<s>
Solutions	O
which	O
update	O
the	O
hash	B-Error_Name
function	I-Error_Name
any	O
time	O
the	O
set	O
is	O
modified	O
are	O
known	O
as	O
dynamic	B-Algorithm
perfect	I-Algorithm
hashing	I-Algorithm
,	O
but	O
these	O
methods	O
are	O
relatively	O
complicated	O
to	O
implement	O
.	O
</s>
<s>
A	O
minimal	O
perfect	B-Algorithm
hash	I-Algorithm
function	I-Algorithm
is	O
a	O
perfect	B-Algorithm
hash	I-Algorithm
function	I-Algorithm
that	O
maps	O
keys	O
to	O
consecutive	O
integers	O
–	O
usually	O
the	O
numbers	O
from	O
to	O
or	O
from	O
to	O
.	O
</s>
<s>
Then	O
is	O
a	O
minimal	O
perfect	B-Algorithm
hash	I-Algorithm
function	I-Algorithm
if	O
and	O
only	O
if	O
implies	O
(	O
injectivity	O
)	O
and	O
there	O
exists	O
an	O
integer	O
such	O
that	O
the	O
range	O
of	O
is	O
.	O
</s>
<s>
It	O
has	O
been	O
proven	O
that	O
a	O
general	O
purpose	O
minimal	O
perfect	B-Algorithm
hash	I-Algorithm
scheme	O
requires	O
at	O
least	O
bits/key	O
.	O
</s>
<s>
Although	O
this	O
space	O
bound	O
has	O
been	O
achieved	O
by	O
theoretical	O
works	O
,	O
in	O
practice	O
,	O
the	O
best	O
known	O
minimal	B-Algorithm
perfect	I-Algorithm
hashing	I-Algorithm
schemes	O
require	O
roughly	O
1.56	O
bits/key	O
if	O
given	O
enough	O
time	O
.	O
</s>
<s>
A	O
hash	B-Error_Name
function	I-Error_Name
is	O
-perfect	O
if	O
at	O
most	O
elements	O
from	O
are	O
mapped	O
onto	O
the	O
same	O
value	O
in	O
the	O
range	O
.	O
</s>
<s>
The	O
"	O
hash	B-Error_Name
,	O
displace	O
,	O
and	O
compress	O
"	O
algorithm	O
can	O
be	O
used	O
to	O
construct	O
-perfect	O
hash	B-Error_Name
functions	O
by	O
allowing	O
up	O
to	O
collisions	B-Algorithm
.	O
</s>
<s>
A	O
minimal	O
perfect	B-Algorithm
hash	I-Algorithm
function	I-Algorithm
is	O
order	O
preserving	O
if	O
keys	O
are	O
given	O
in	O
some	O
order	O
and	O
for	O
any	O
keys	O
and	O
,	O
implies	O
.	O
</s>
<s>
A	O
simple	O
implementation	O
of	O
order-preserving	O
minimal	O
perfect	B-Algorithm
hash	I-Algorithm
functions	I-Algorithm
with	O
constant	O
access	O
time	O
is	O
to	O
use	O
an	O
(	O
ordinary	O
)	O
perfect	B-Algorithm
hash	I-Algorithm
function	I-Algorithm
or	O
cuckoo	B-Algorithm
hashing	I-Algorithm
to	O
store	O
a	O
lookup	B-Data_Structure
table	I-Data_Structure
of	O
the	O
positions	O
of	O
each	O
key	O
.	O
</s>
<s>
If	O
the	O
keys	O
to	O
be	O
hashed	O
are	O
themselves	O
stored	O
in	O
a	O
sorted	O
array	O
,	O
it	O
is	O
possible	O
to	O
store	O
a	O
small	O
number	O
of	O
additional	O
bits	O
per	O
key	O
in	O
a	O
data	O
structure	O
that	O
can	O
be	O
used	O
to	O
compute	O
hash	B-Error_Name
values	I-Error_Name
quickly	O
.	O
</s>
<s>
Order-preserving	O
minimal	O
perfect	B-Algorithm
hash	I-Algorithm
functions	I-Algorithm
require	O
necessarily	O
bits	O
to	O
be	O
represented	O
.	O
</s>
<s>
A	O
simple	O
alternative	O
to	O
perfect	B-Algorithm
hashing	I-Algorithm
,	O
which	O
also	O
allows	O
dynamic	O
updates	O
,	O
is	O
cuckoo	B-Algorithm
hashing	I-Algorithm
.	O
</s>
<s>
This	O
scheme	O
maps	O
keys	O
to	O
two	O
or	O
more	O
locations	O
within	O
a	O
range	O
(	O
unlike	O
perfect	B-Algorithm
hashing	I-Algorithm
which	O
maps	O
each	O
key	O
to	O
a	O
single	O
location	O
)	O
but	O
does	O
so	O
in	O
such	O
a	O
way	O
that	O
the	O
keys	O
can	O
be	O
assigned	O
one-to-one	O
to	O
locations	O
to	O
which	O
they	O
have	O
been	O
mapped	O
.	O
</s>
<s>
Lookups	B-Data_Structure
with	O
this	O
scheme	O
are	O
slower	O
,	O
because	O
multiple	O
locations	O
must	O
be	O
checked	O
,	O
but	O
nevertheless	O
take	O
constant	O
worst-case	O
time	O
.	O
</s>
