<s>
In	O
computing	O
,	O
a	O
hash	B-Algorithm
table	I-Algorithm
,	O
also	O
known	O
as	O
hash	B-Language
map	I-Language
,	O
is	O
a	O
data	B-General_Concept
structure	I-General_Concept
that	O
implements	O
an	O
associative	B-Application
array	I-Application
or	O
dictionary	B-Application
.	O
</s>
<s>
It	O
is	O
an	O
abstract	O
data	O
type	O
that	O
maps	O
keys	B-Application
to	O
values	O
.	O
</s>
<s>
A	O
hash	B-Algorithm
table	I-Algorithm
uses	O
a	O
hash	B-Error_Name
function	I-Error_Name
to	O
compute	O
an	O
index	O
,	O
also	O
called	O
a	O
hash	B-Error_Name
code	I-Error_Name
,	O
into	O
an	O
array	O
of	O
buckets	O
or	O
slots	O
,	O
from	O
which	O
the	O
desired	O
value	O
can	O
be	O
found	O
.	O
</s>
<s>
During	O
lookup	B-Data_Structure
,	O
the	O
key	O
is	O
hashed	O
and	O
the	O
resulting	O
hash	B-Error_Name
indicates	O
where	O
the	O
corresponding	O
value	O
is	O
stored	O
.	O
</s>
<s>
Ideally	O
,	O
the	O
hash	B-Error_Name
function	I-Error_Name
will	O
assign	O
each	O
key	O
to	O
a	O
unique	O
bucket	O
,	O
but	O
most	O
hash	B-Algorithm
table	I-Algorithm
designs	O
employ	O
an	O
imperfect	O
hash	B-Error_Name
function	I-Error_Name
,	O
which	O
might	O
cause	O
hash	B-Algorithm
collisions	I-Algorithm
where	O
the	O
hash	B-Error_Name
function	I-Error_Name
generates	O
the	O
same	O
index	O
for	O
more	O
than	O
one	O
key	O
.	O
</s>
<s>
Such	O
collisions	B-Algorithm
are	O
typically	O
accommodated	O
in	O
some	O
way	O
.	O
</s>
<s>
In	O
a	O
well-dimensioned	O
hash	B-Algorithm
table	I-Algorithm
,	O
the	O
average	O
time	O
complexity	O
for	O
each	O
lookup	B-Data_Structure
is	O
independent	O
of	O
the	O
number	O
of	O
elements	O
stored	O
in	O
the	O
table	B-Data_Structure
.	O
</s>
<s>
Many	O
hash	B-Algorithm
table	I-Algorithm
designs	O
also	O
allow	O
arbitrary	O
insertions	O
and	O
deletions	O
of	O
key	B-Application
–	I-Application
value	I-Application
pairs	I-Application
,	O
at	O
amortized	B-General_Concept
constant	O
average	O
cost	O
per	O
operation	O
.	O
</s>
<s>
If	O
memory	B-General_Concept
is	O
infinite	O
,	O
the	O
entire	O
key	O
can	O
be	O
used	O
directly	O
as	O
an	O
index	O
to	O
locate	O
its	O
value	O
with	O
a	O
single	O
memory	B-General_Concept
access	O
.	O
</s>
<s>
On	O
the	O
other	O
hand	O
,	O
if	O
infinite	O
time	O
is	O
available	O
,	O
values	O
can	O
be	O
stored	O
without	O
regard	O
for	O
their	O
keys	B-Application
,	O
and	O
a	O
binary	O
search	O
or	O
linear	B-Algorithm
search	I-Algorithm
can	O
be	O
used	O
to	O
retrieve	O
the	O
element	O
.	O
</s>
<s>
In	O
many	O
situations	O
,	O
hash	B-Algorithm
tables	I-Algorithm
turn	O
out	O
to	O
be	O
on	O
average	O
more	O
efficient	O
than	O
search	B-Data_Structure
trees	I-Data_Structure
or	O
any	O
other	O
table	B-Data_Structure
lookup	I-Data_Structure
structure	O
.	O
</s>
<s>
For	O
this	O
reason	O
,	O
they	O
are	O
widely	O
used	O
in	O
many	O
kinds	O
of	O
computer	O
software	O
,	O
particularly	O
for	O
associative	B-Application
arrays	I-Application
,	O
database	O
indexing	O
,	O
caches	B-General_Concept
,	O
and	O
sets	O
.	O
</s>
<s>
Open	B-Algorithm
addressing	I-Algorithm
was	O
later	O
proposed	O
by	O
A	O
.	O
D	O
.	O
Linh	O
building	O
on	O
Luhn	O
's	O
paper	O
.	O
</s>
<s>
Around	O
the	O
same	O
time	O
,	O
Gene	O
Amdahl	O
,	O
Elaine	O
M	O
.	O
McGraw	O
,	O
Nathaniel	O
Rochester	O
,	O
and	O
Arthur	O
Samuel	O
of	O
IBM	O
Research	O
implemented	O
hashing	O
for	O
the	O
IBM	B-Device
701	I-Device
assembler	O
.	O
</s>
<s>
Open	B-Algorithm
addressing	I-Algorithm
with	O
linear	B-Algorithm
probing	I-Algorithm
is	O
credited	O
to	O
Amdahl	O
,	O
although	O
Ershov	O
independently	O
had	O
the	O
same	O
idea	O
.	O
</s>
<s>
The	O
term	O
"	O
open	B-Algorithm
addressing	I-Algorithm
"	O
was	O
coined	O
by	O
W	O
.	O
Wesley	O
Peterson	O
on	O
his	O
article	O
which	O
discusses	O
the	O
problem	O
of	O
search	O
in	O
large	O
files	O
.	O
</s>
<s>
The	O
first	O
published	O
work	O
on	O
hashing	O
with	O
chaining	O
is	O
credited	O
to	O
Arnold	O
Dumey	O
,	O
who	O
discussed	O
the	O
idea	O
of	O
using	O
remainder	O
module	O
a	O
prime	O
as	O
a	O
hash	B-Error_Name
function	I-Error_Name
.	O
</s>
<s>
A	O
theoretical	O
analysis	O
of	O
linear	B-Algorithm
probing	I-Algorithm
was	O
submitted	O
originally	O
by	O
Konheim	O
and	O
Weiss	O
.	O
</s>
<s>
An	O
associative	B-Application
array	I-Application
stores	O
a	O
set	O
of	O
(	O
key	O
,	O
value	O
)	O
pairs	O
and	O
allows	O
insertion	O
,	O
deletion	O
,	O
and	O
lookup	B-Data_Structure
(	O
search	O
)	O
,	O
with	O
the	O
constraint	O
of	O
unique	B-Application
keys	I-Application
.	O
</s>
<s>
In	O
the	O
hash	B-Algorithm
table	I-Algorithm
implementation	O
of	O
associative	B-Application
arrays	I-Application
,	O
an	O
array	O
of	O
length	O
is	O
partially	O
filled	O
with	O
elements	O
,	O
where	O
.	O
</s>
<s>
A	O
value	O
gets	O
stored	O
at	O
an	O
index	O
location	O
,	O
where	O
is	O
a	O
hash	B-Error_Name
function	I-Error_Name
,	O
and	O
.	O
</s>
<s>
Under	O
reasonable	O
assumptions	O
,	O
hash	B-Algorithm
tables	I-Algorithm
have	O
better	O
time	O
complexity	O
bounds	O
on	O
search	O
,	O
delete	O
,	O
and	O
insert	O
operations	O
in	O
comparison	O
to	O
self-balancing	B-Data_Structure
binary	I-Data_Structure
search	I-Data_Structure
trees	I-Data_Structure
.	O
</s>
<s>
Hash	B-Algorithm
tables	I-Algorithm
are	O
also	O
commonly	O
used	O
to	O
implement	O
sets	O
,	O
by	O
omitting	O
the	O
stored	O
value	O
for	O
each	O
key	O
and	O
merely	O
tracking	O
whether	O
the	O
key	O
is	O
present	O
.	O
</s>
<s>
A	O
load	O
factor	O
is	O
a	O
critical	O
statistic	O
of	O
a	O
hash	B-Algorithm
table	I-Algorithm
,	O
and	O
is	O
defined	O
as	O
follows	O
:	O
</s>
<s>
is	O
the	O
number	O
of	O
entries	O
occupied	O
in	O
the	O
hash	B-Algorithm
table	I-Algorithm
.	O
</s>
<s>
The	O
performance	O
of	O
the	O
hash	B-Algorithm
table	I-Algorithm
deteriorates	O
in	O
relation	O
to	O
the	O
load	O
factor	O
.	O
</s>
<s>
Therefore	O
a	O
hash	B-Algorithm
table	I-Algorithm
is	O
resized	O
or	O
rehashed	O
if	O
the	O
load	O
factor	O
approaches	O
1	O
.	O
</s>
<s>
A	O
table	B-Data_Structure
is	O
also	O
resized	O
if	O
the	O
load	O
factor	O
drops	O
below	O
.	O
</s>
<s>
A	O
hash	B-Error_Name
function	I-Error_Name
maps	O
the	O
universe	O
of	O
keys	B-Application
to	O
array	O
indices	O
or	O
slots	O
within	O
the	O
table	B-Data_Structure
for	O
each	O
where	O
and	O
.	O
</s>
<s>
The	O
conventional	O
implementations	O
of	O
hash	B-Error_Name
functions	I-Error_Name
are	O
based	O
on	O
the	O
integer	O
universe	O
assumption	O
that	O
all	O
elements	O
of	O
the	O
table	B-Data_Structure
stem	O
from	O
the	O
universe	O
,	O
where	O
the	O
bit	B-Algorithm
length	I-Algorithm
of	O
is	O
confined	O
within	O
the	O
word	O
size	O
of	O
a	O
computer	B-General_Concept
architecture	I-General_Concept
.	O
</s>
<s>
A	O
perfect	B-Algorithm
hash	I-Algorithm
function	I-Algorithm
is	O
defined	O
as	O
an	O
injective	O
function	O
such	O
that	O
each	O
element	O
in	O
maps	O
to	O
a	O
unique	O
value	O
in	O
.	O
</s>
<s>
A	O
perfect	B-Algorithm
hash	I-Algorithm
function	I-Algorithm
can	O
be	O
created	O
if	O
all	O
the	O
keys	B-Application
are	O
known	O
ahead	O
of	O
time	O
.	O
</s>
<s>
The	O
schemes	O
of	O
hashing	O
used	O
in	O
integer	O
universe	O
assumption	O
include	O
hashing	O
by	O
division	O
,	O
hashing	O
by	O
multiplication	O
,	O
universal	B-Algorithm
hashing	I-Algorithm
,	O
dynamic	B-Algorithm
perfect	I-Algorithm
hashing	I-Algorithm
,	O
and	O
static	B-Algorithm
perfect	I-Algorithm
hashing	I-Algorithm
.	O
</s>
<s>
Where	O
is	O
the	O
hash	B-Error_Name
digest	O
of	O
and	O
is	O
the	O
size	O
of	O
the	O
table	B-Data_Structure
.	O
</s>
<s>
Where	O
is	O
a	O
real-valued	O
constant	O
and	O
is	O
the	O
size	O
of	O
the	O
table	B-Data_Structure
.	O
</s>
<s>
Although	O
any	O
value	O
produces	O
a	O
hash	B-Error_Name
function	I-Error_Name
,	O
Donald	O
Knuth	O
suggests	O
using	O
the	O
golden	O
ratio	O
.	O
</s>
<s>
Uniform	O
distribution	O
of	O
the	O
hash	B-Error_Name
values	I-Error_Name
is	O
a	O
fundamental	O
requirement	O
of	O
a	O
hash	B-Error_Name
function	I-Error_Name
.	O
</s>
<s>
A	O
non-uniform	O
distribution	O
increases	O
the	O
number	O
of	O
collisions	B-Algorithm
and	O
the	O
cost	O
of	O
resolving	O
them	O
.	O
</s>
<s>
The	O
distribution	O
needs	O
to	O
be	O
uniform	O
only	O
for	O
table	B-Data_Structure
sizes	O
that	O
occur	O
in	O
the	O
application	O
.	O
</s>
<s>
In	O
particular	O
,	O
if	O
one	O
uses	O
dynamic	O
resizing	O
with	O
exact	O
doubling	O
and	O
halving	O
of	O
the	O
table	B-Data_Structure
size	O
,	O
then	O
the	O
hash	B-Error_Name
function	I-Error_Name
needs	O
to	O
be	O
uniform	O
only	O
when	O
the	O
size	O
is	O
a	O
power	O
of	O
two	O
.	O
</s>
<s>
Here	O
the	O
index	O
can	O
be	O
computed	O
as	O
some	O
range	O
of	O
bits	O
of	O
the	O
hash	B-Error_Name
function	I-Error_Name
.	O
</s>
<s>
On	O
the	O
other	O
hand	O
,	O
some	O
hashing	B-Error_Name
algorithms	I-Error_Name
prefer	O
to	O
have	O
the	O
size	O
be	O
a	O
prime	O
number	O
.	O
</s>
<s>
For	O
open	B-Algorithm
addressing	I-Algorithm
schemes	O
,	O
the	O
hash	B-Error_Name
function	I-Error_Name
should	O
also	O
avoid	O
clustering	B-Algorithm
,	O
the	O
mapping	O
of	O
two	O
or	O
more	O
keys	B-Application
to	O
consecutive	O
slots	O
.	O
</s>
<s>
Such	O
clustering	B-Algorithm
may	O
cause	O
the	O
lookup	B-Data_Structure
cost	O
to	O
skyrocket	O
,	O
even	O
if	O
the	O
load	O
factor	O
is	O
low	O
and	O
collisions	B-Algorithm
are	O
infrequent	O
.	O
</s>
<s>
The	O
popular	O
multiplicative	O
hash	B-Error_Name
is	O
claimed	O
to	O
have	O
particularly	O
poor	O
clustering	B-Algorithm
behavior	O
.	O
</s>
<s>
K-independent	B-Error_Name
hashing	I-Error_Name
offers	O
a	O
way	O
to	O
prove	O
a	O
certain	O
hash	B-Error_Name
function	I-Error_Name
does	O
not	O
have	O
bad	O
keysets	O
for	O
a	O
given	O
type	O
of	O
hashtable	B-Algorithm
.	O
</s>
<s>
A	O
number	O
of	O
K-independence	O
results	O
are	O
known	O
for	O
collision	O
resolution	O
schemes	O
such	O
as	O
linear	B-Algorithm
probing	I-Algorithm
and	O
cuckoo	B-Algorithm
hashing	I-Algorithm
.	O
</s>
<s>
Since	O
K-independence	O
can	O
prove	O
a	O
hash	B-Error_Name
function	I-Error_Name
works	O
,	O
one	O
can	O
then	O
focus	O
on	O
finding	O
the	O
fastest	O
possible	O
such	O
hash	B-Error_Name
function	I-Error_Name
.	O
</s>
<s>
The	O
first	O
part	O
is	O
computing	O
a	O
hash	B-Error_Name
function	I-Error_Name
which	O
transforms	O
the	O
search	O
key	O
into	O
an	O
array	O
index	O
.	O
</s>
<s>
The	O
ideal	O
case	O
is	O
such	O
that	O
no	O
two	O
search	O
keys	B-Application
hashes	B-Error_Name
to	O
the	O
same	O
array	O
index	O
.	O
</s>
<s>
The	O
two	O
common	O
methods	O
for	O
collision	O
resolution	O
are	O
separate	O
chaining	O
and	O
open	B-Algorithm
addressing	I-Algorithm
.	O
</s>
<s>
In	O
separate	O
chaining	O
,	O
the	O
process	O
involves	O
building	O
a	O
linked	B-Data_Structure
list	I-Data_Structure
with	O
key	B-Application
–	I-Application
value	I-Application
pair	I-Application
for	O
each	O
search	O
array	O
index	O
.	O
</s>
<s>
The	O
collided	O
items	O
are	O
chained	O
together	O
through	O
a	O
single	O
linked	B-Data_Structure
list	I-Data_Structure
,	O
which	O
can	O
be	O
traversed	O
to	O
access	O
the	O
item	O
with	O
a	O
unique	O
search	O
key	O
.	O
</s>
<s>
Collision	O
resolution	O
through	O
chaining	O
with	O
linked	B-Data_Structure
list	I-Data_Structure
is	O
a	O
common	O
method	O
of	O
implementation	O
of	O
hash	B-Algorithm
tables	I-Algorithm
.	O
</s>
<s>
Let	O
and	O
be	O
the	O
hash	B-Algorithm
table	I-Algorithm
and	O
the	O
node	O
respectively	O
,	O
the	O
operation	O
involves	O
as	O
follows	O
:	O
</s>
<s>
If	O
the	O
keys	B-Application
are	O
ordered	O
,	O
it	O
could	O
be	O
efficient	O
to	O
use	O
"	O
self-organizing	B-Data_Structure
"	O
concepts	O
such	O
as	O
using	O
a	O
self-balancing	B-Data_Structure
binary	I-Data_Structure
search	I-Data_Structure
tree	I-Data_Structure
,	O
through	O
which	O
the	O
theoretical	B-General_Concept
worst	I-General_Concept
case	I-General_Concept
could	O
be	O
brought	O
down	O
to	O
,	O
although	O
it	O
introduces	O
additional	O
complexities	O
.	O
</s>
<s>
In	O
dynamic	B-Algorithm
perfect	I-Algorithm
hashing	I-Algorithm
,	O
two-level	O
hash	B-Algorithm
tables	I-Algorithm
are	O
used	O
to	O
reduce	O
the	O
look-up	B-Data_Structure
complexity	O
to	O
be	O
a	O
guaranteed	O
in	O
the	O
worst	O
case	O
.	O
</s>
<s>
In	O
this	O
technique	O
,	O
the	O
buckets	O
of	O
entries	O
are	O
organized	O
as	O
perfect	B-Algorithm
hash	I-Algorithm
tables	I-Algorithm
with	O
slots	O
providing	O
constant	O
worst-case	O
lookup	B-Data_Structure
time	O
,	O
and	O
low	O
amortized	B-General_Concept
time	I-General_Concept
for	O
insertion	O
.	O
</s>
<s>
A	O
study	O
shows	O
array	O
based	O
separate	O
chaining	O
to	O
be	O
97%	O
more	O
performant	O
when	O
compared	O
to	O
the	O
standard	O
linked	B-Data_Structure
list	I-Data_Structure
method	O
under	O
heavy	O
load	O
.	O
</s>
<s>
Techniques	O
such	O
as	O
using	O
fusion	B-Data_Structure
tree	I-Data_Structure
for	O
each	O
buckets	O
also	O
result	O
in	O
constant	O
time	O
for	O
all	O
operations	O
with	O
high	O
probability	O
.	O
</s>
<s>
The	O
linked	B-Data_Structure
list	I-Data_Structure
of	O
separate	O
chaining	O
implementation	O
may	O
not	O
be	O
cache-conscious	B-Application
due	O
to	O
spatial	O
locality	O
—	O
locality	B-General_Concept
of	I-General_Concept
reference	I-General_Concept
—	O
when	O
the	O
nodes	O
of	O
the	O
linked	B-Data_Structure
list	I-Data_Structure
are	O
scattered	O
across	O
memory	B-General_Concept
,	O
thus	O
the	O
list	O
traversal	O
during	O
insert	O
and	O
search	O
may	O
entail	O
CPU	B-General_Concept
cache	I-General_Concept
inefficiencies	O
.	O
</s>
<s>
In	O
cache-conscious	B-Application
variants	I-Application
,	O
a	O
dynamic	B-Data_Structure
array	I-Data_Structure
found	O
to	O
be	O
more	O
cache-friendly	B-General_Concept
is	O
used	O
in	O
the	O
place	O
where	O
a	O
linked	B-Data_Structure
list	I-Data_Structure
or	O
self-balancing	B-Data_Structure
binary	I-Data_Structure
search	I-Data_Structure
trees	I-Data_Structure
is	O
usually	O
deployed	O
for	O
collision	O
resolution	O
through	O
separate	O
chaining	O
,	O
since	O
the	O
contiguous	O
allocation	O
pattern	O
of	O
the	O
array	O
could	O
be	O
exploited	O
by	O
hardware-cache	B-General_Concept
prefetchers	I-General_Concept
—	O
such	O
as	O
translation	B-Architecture
lookaside	I-Architecture
buffer	I-Architecture
—	O
resulting	O
in	O
reduced	O
access	O
time	O
and	O
memory	B-General_Concept
consumption	O
.	O
</s>
<s>
Open	B-Algorithm
addressing	I-Algorithm
is	O
another	O
collision	O
resolution	O
technique	O
in	O
which	O
every	O
entry	O
record	O
is	O
stored	O
in	O
the	O
bucket	O
array	O
itself	O
,	O
and	O
the	O
hash	B-Error_Name
resolution	O
is	O
performed	O
through	O
probing	O
.	O
</s>
<s>
Linear	B-Algorithm
probing	I-Algorithm
,	O
in	O
which	O
the	O
interval	O
between	O
probes	O
is	O
fixed	O
(	O
usually	O
1	O
)	O
.	O
</s>
<s>
Quadratic	B-Algorithm
probing	I-Algorithm
,	O
in	O
which	O
the	O
interval	O
between	O
probes	O
is	O
increased	O
by	O
adding	O
the	O
successive	O
outputs	O
of	O
a	O
quadratic	O
polynomial	O
to	O
the	O
value	O
given	O
by	O
the	O
original	O
hash	B-Error_Name
computation	O
.	O
</s>
<s>
Double	B-Algorithm
hashing	I-Algorithm
,	O
in	O
which	O
the	O
interval	O
between	O
probes	O
is	O
computed	O
by	O
a	O
secondary	O
hash	B-Error_Name
function	I-Error_Name
.	O
</s>
<s>
The	O
performance	O
of	O
open	B-Algorithm
addressing	I-Algorithm
may	O
be	O
slower	O
compared	O
to	O
separate	O
chaining	O
since	O
the	O
probe	O
sequence	O
increases	O
when	O
the	O
load	O
factor	O
approaches	O
1	O
.	O
</s>
<s>
The	O
probing	O
results	O
in	O
an	O
infinite	B-Algorithm
loop	I-Algorithm
if	O
the	O
load	O
factor	O
reaches	O
1	O
,	O
in	O
the	O
case	O
of	O
a	O
completely	O
filled	O
table	B-Data_Structure
.	O
</s>
<s>
The	O
average	O
cost	O
of	O
linear	B-Algorithm
probing	I-Algorithm
depends	O
on	O
the	O
hash	B-Error_Name
function	I-Error_Name
's	O
ability	O
to	O
distribute	O
the	O
elements	O
uniformly	O
throughout	O
the	O
table	B-Data_Structure
to	O
avoid	O
clustering	B-Algorithm
,	O
since	O
formation	O
of	O
clusters	O
would	O
result	O
in	O
increased	O
search	O
time	O
.	O
</s>
<s>
Since	O
the	O
slots	O
are	O
located	O
in	O
successive	O
locations	O
,	O
linear	B-Algorithm
probing	I-Algorithm
could	O
lead	O
to	O
better	O
utilization	O
of	O
CPU	B-General_Concept
cache	I-General_Concept
due	O
to	O
locality	O
of	O
references	O
resulting	O
in	O
reduced	O
memory	B-General_Concept
latency	I-General_Concept
.	O
</s>
<s>
Coalesced	B-Algorithm
hashing	I-Algorithm
is	O
a	O
hybrid	O
of	O
both	O
separate	O
chaining	O
and	O
open	B-Algorithm
addressing	I-Algorithm
in	O
which	O
the	O
buckets	O
or	O
nodes	O
link	O
within	O
the	O
table	B-Data_Structure
.	O
</s>
<s>
The	O
algorithm	O
is	O
ideally	O
suited	O
for	O
fixed	B-General_Concept
memory	I-General_Concept
allocation	I-General_Concept
.	O
</s>
<s>
The	O
collision	O
in	O
coalesced	B-Algorithm
hashing	I-Algorithm
is	O
resolved	O
by	O
identifying	O
the	O
largest-indexed	O
empty	O
slot	O
on	O
the	O
hash	B-Algorithm
table	I-Algorithm
,	O
then	O
the	O
colliding	O
value	O
is	O
inserted	O
into	O
that	O
slot	O
.	O
</s>
<s>
The	O
bucket	O
is	O
also	O
linked	O
to	O
the	O
inserted	O
node	O
's	O
slot	O
which	O
contains	O
its	O
colliding	O
hash	B-Error_Name
address	O
.	O
</s>
<s>
Cuckoo	B-Algorithm
hashing	I-Algorithm
is	O
a	O
form	O
of	O
open	B-Algorithm
addressing	I-Algorithm
collision	O
resolution	O
technique	O
which	O
guarantees	O
worst-case	O
lookup	B-Data_Structure
complexity	O
and	O
constant	O
amortized	B-General_Concept
time	I-General_Concept
for	O
insertions	O
.	O
</s>
<s>
The	O
collision	O
is	O
resolved	O
through	O
maintaining	O
two	O
hash	B-Algorithm
tables	I-Algorithm
,	O
each	O
having	O
its	O
own	O
hashing	B-Error_Name
function	I-Error_Name
,	O
and	O
collided	O
slot	O
gets	O
replaced	O
with	O
the	O
given	O
item	O
,	O
and	O
the	O
preoccupied	O
element	O
of	O
the	O
slot	O
gets	O
displaced	O
into	O
the	O
other	O
hash	B-Algorithm
table	I-Algorithm
.	O
</s>
<s>
The	O
process	O
continues	O
until	O
every	O
key	O
has	O
its	O
own	O
spot	O
in	O
the	O
empty	O
buckets	O
of	O
the	O
tables	O
;	O
if	O
the	O
procedure	O
enters	O
into	O
infinite	B-Algorithm
loop	I-Algorithm
—	O
which	O
is	O
identified	O
through	O
maintaining	O
a	O
threshold	O
loop	O
counter	O
—	O
both	O
hash	B-Algorithm
tables	I-Algorithm
get	O
rehashed	O
with	O
newer	O
hash	B-Error_Name
functions	I-Error_Name
and	O
the	O
procedure	O
continues	O
.	O
</s>
<s>
Hopscotch	B-Algorithm
hashing	I-Algorithm
is	O
an	O
open	B-Algorithm
addressing	I-Algorithm
based	O
algorithm	O
which	O
combines	O
the	O
elements	O
of	O
cuckoo	B-Algorithm
hashing	I-Algorithm
,	O
linear	B-Algorithm
probing	I-Algorithm
and	O
chaining	O
through	O
the	O
notion	O
of	O
a	O
neighbourhood	O
of	O
buckets	O
—	O
the	O
subsequent	O
buckets	O
around	O
any	O
given	O
occupied	O
bucket	O
,	O
also	O
called	O
a	O
"	O
virtual	O
"	O
bucket	O
.	O
</s>
<s>
The	O
algorithm	O
is	O
designed	O
to	O
deliver	O
better	O
performance	O
when	O
the	O
load	O
factor	O
of	O
the	O
hash	B-Algorithm
table	I-Algorithm
grows	O
beyond	O
90%	O
;	O
it	O
also	O
provides	O
high	O
throughput	O
in	O
concurrent	B-Architecture
settings	I-Architecture
,	O
thus	O
well	O
suited	O
for	O
implementing	O
resizable	O
concurrent	B-Algorithm
hash	I-Algorithm
table	I-Algorithm
.	O
</s>
<s>
The	O
neighbourhood	O
characteristic	O
of	O
hopscotch	B-Algorithm
hashing	I-Algorithm
guarantees	O
a	O
property	O
that	O
,	O
the	O
cost	O
of	O
finding	O
the	O
desired	O
item	O
from	O
any	O
given	O
buckets	O
within	O
the	O
neighbourhood	O
is	O
very	O
close	O
to	O
the	O
cost	O
of	O
finding	O
it	O
in	O
the	O
bucket	O
itself	O
;	O
the	O
algorithm	O
attempts	O
to	O
be	O
an	O
item	O
into	O
its	O
neighbourhood	O
—	O
with	O
a	O
possible	O
cost	O
involved	O
in	O
displacing	O
other	O
items	O
.	O
</s>
<s>
Each	O
bucket	O
within	O
the	O
hash	B-Algorithm
table	I-Algorithm
includes	O
an	O
additional	O
"	O
hop-information	O
"	O
—	O
an	O
H-bit	O
bit	B-Data_Structure
array	I-Data_Structure
for	O
indicating	O
the	O
relative	O
distance	O
of	O
the	O
item	O
which	O
was	O
originally	O
hashed	O
into	O
the	O
current	O
virtual	O
bucket	O
within	O
H-1	O
entries	O
.	O
</s>
<s>
Let	O
and	O
be	O
the	O
key	O
to	O
be	O
inserted	O
and	O
bucket	O
to	O
which	O
the	O
key	O
is	O
hashed	O
into	O
respectively	O
;	O
several	O
cases	O
are	O
involved	O
in	O
the	O
insertion	O
procedure	O
such	O
that	O
the	O
neighbourhood	O
property	O
of	O
the	O
algorithm	O
is	O
vowed	O
:	O
if	O
is	O
empty	O
,	O
the	O
element	O
is	O
inserted	O
,	O
and	O
the	O
leftmost	O
bit	O
of	O
bitmap	O
is	O
set	O
to	O
1	O
;	O
if	O
not	O
empty	O
,	O
linear	B-Algorithm
probing	I-Algorithm
is	O
used	O
for	O
finding	O
an	O
empty	O
slot	O
in	O
the	O
table	B-Data_Structure
,	O
the	O
bitmap	O
of	O
the	O
bucket	O
gets	O
updated	O
followed	O
by	O
the	O
insertion	O
;	O
if	O
the	O
empty	O
slot	O
is	O
not	O
within	O
the	O
range	O
of	O
the	O
neighbourhood	O
,	O
i.e.	O
</s>
<s>
H-1	O
,	O
subsequent	O
swap	O
and	O
hop-info	O
bit	B-Data_Structure
array	I-Data_Structure
manipulation	O
of	O
each	O
bucket	O
is	O
performed	O
in	O
accordance	O
with	O
its	O
neighbourhood	O
invariant	O
properties	O
.	O
</s>
<s>
Robin	O
hood	O
hashing	O
is	O
an	O
open	B-Algorithm
addressing	I-Algorithm
based	O
collision	O
resolution	O
algorithm	O
;	O
the	O
collisions	B-Algorithm
are	O
resolved	O
through	O
favouring	O
the	O
displacement	O
of	O
the	O
element	O
that	O
is	O
farthest	O
—	O
or	O
longest	O
probe	O
sequence	O
length	O
(	O
PSL	O
)	O
—	O
from	O
its	O
"	O
home	O
location	O
"	O
i.e.	O
</s>
<s>
dealing	O
with	O
cluster	B-Algorithm
formation	O
in	O
the	O
hash	B-Algorithm
table	I-Algorithm
.	O
</s>
<s>
Each	O
node	O
within	O
the	O
hash	B-Algorithm
table	I-Algorithm
that	O
uses	O
robin	O
hood	O
hashing	O
should	O
be	O
augmented	O
to	O
store	O
an	O
extra	O
PSL	O
value	O
.	O
</s>
<s>
Let	O
be	O
the	O
key	O
to	O
be	O
inserted	O
,	O
be	O
the	O
(	O
incremental	O
)	O
PSL	O
length	O
of	O
,	O
be	O
the	O
hash	B-Algorithm
table	I-Algorithm
and	O
be	O
the	O
index	O
,	O
the	O
insertion	O
procedure	O
is	O
as	O
follows	O
:	O
</s>
<s>
Repeated	O
insertions	O
cause	O
the	O
number	O
of	O
entries	O
in	O
a	O
hash	B-Algorithm
table	I-Algorithm
to	O
grow	O
,	O
which	O
consequently	O
increases	O
the	O
load	O
factor	O
;	O
to	O
maintain	O
the	O
amortized	B-General_Concept
performance	O
of	O
the	O
lookup	B-Data_Structure
and	O
insertion	O
operations	O
,	O
a	O
hash	B-Algorithm
table	I-Algorithm
is	O
dynamically	O
resized	O
and	O
the	O
items	O
of	O
the	O
tables	O
are	O
rehashed	O
into	O
the	O
buckets	O
of	O
the	O
new	O
hash	B-Algorithm
table	I-Algorithm
,	O
since	O
the	O
items	O
cannot	O
be	O
copied	O
over	O
as	O
varying	O
table	B-Data_Structure
sizes	O
results	O
in	O
different	O
hash	B-Error_Name
value	I-Error_Name
due	O
to	O
modulo	O
operation	O
.	O
</s>
<s>
If	O
a	O
hash	B-Algorithm
table	I-Algorithm
becomes	O
"	O
too	O
empty	O
"	O
after	O
deleting	O
some	O
elements	O
,	O
resizing	O
may	O
be	O
performed	O
to	O
avoid	O
excessive	O
memory	B-General_Concept
usage	I-General_Concept
.	O
</s>
<s>
Generally	O
,	O
a	O
new	O
hash	B-Algorithm
table	I-Algorithm
with	O
a	O
size	O
double	O
that	O
of	O
the	O
original	O
hash	B-Algorithm
table	I-Algorithm
gets	O
allocated	B-General_Concept
privately	O
and	O
every	O
item	O
in	O
the	O
original	O
hash	B-Algorithm
table	I-Algorithm
gets	O
moved	O
to	O
the	O
newly	O
allocated	B-General_Concept
one	O
by	O
computing	O
the	O
hash	B-Error_Name
values	I-Error_Name
of	O
the	O
items	O
followed	O
by	O
the	O
insertion	O
operation	O
.	O
</s>
<s>
Rehashing	B-Algorithm
is	O
computationally	O
expensive	O
despite	O
its	O
simplicity	O
.	O
</s>
<s>
Some	O
hash	B-Algorithm
table	I-Algorithm
implementations	O
,	O
notably	O
in	O
real-time	B-General_Concept
systems	I-General_Concept
,	O
cannot	O
pay	O
the	O
price	O
of	O
enlarging	O
the	O
hash	B-Algorithm
table	I-Algorithm
all	O
at	O
once	O
,	O
because	O
it	O
may	O
interrupt	O
time-critical	O
operations	O
.	O
</s>
<s>
If	O
one	O
cannot	O
avoid	O
dynamic	O
resizing	O
,	O
a	O
solution	O
is	O
to	O
perform	O
the	O
resizing	O
gradually	O
to	O
avoid	O
storage	O
blip	O
—	O
typically	O
at	O
50%	O
of	O
new	O
table	B-Data_Structure
's	O
size	O
—	O
during	O
rehashing	B-Algorithm
and	O
to	O
avoid	O
memory	B-Architecture
fragmentation	I-Architecture
that	O
triggers	O
heap	B-General_Concept
compaction	I-General_Concept
due	O
to	O
deallocation	B-General_Concept
of	O
large	O
memory	B-General_Concept
blocks	I-General_Concept
caused	O
by	O
the	O
old	O
hash	B-Algorithm
table	I-Algorithm
.	O
</s>
<s>
In	O
such	O
case	O
,	O
the	O
rehashing	B-Algorithm
operation	O
is	O
done	O
incrementally	O
through	O
extending	O
prior	O
memory	B-General_Concept
block	O
allocated	B-General_Concept
for	O
the	O
old	O
hash	B-Algorithm
table	I-Algorithm
such	O
that	O
the	O
buckets	O
of	O
the	O
hash	B-Algorithm
table	I-Algorithm
remain	O
unaltered	O
.	O
</s>
<s>
A	O
common	O
approach	O
for	O
amortized	B-General_Concept
rehashing	B-Algorithm
involves	O
maintaining	O
two	O
hash	B-Error_Name
functions	I-Error_Name
and	O
.	O
</s>
<s>
The	O
process	O
of	O
rehashing	B-Algorithm
a	O
bucket	O
's	O
items	O
in	O
accordance	O
with	O
the	O
new	O
hash	B-Error_Name
function	I-Error_Name
is	O
termed	O
as	O
cleaning	O
,	O
which	O
is	O
implemented	O
through	O
command	B-Language
pattern	I-Language
by	O
encapsulating	O
the	O
operations	O
such	O
as	O
,	O
and	O
through	O
a	O
wrapper	O
such	O
that	O
each	O
element	O
in	O
the	O
bucket	O
gets	O
rehashed	O
and	O
its	O
procedure	O
involve	O
as	O
follows	O
:	O
</s>
<s>
Linear	B-Algorithm
hashing	I-Algorithm
is	O
an	O
implementation	O
of	O
the	O
hash	B-Algorithm
table	I-Algorithm
which	O
enables	O
dynamic	O
growths	O
or	O
shrinks	O
of	O
the	O
table	B-Data_Structure
one	O
bucket	O
at	O
a	O
time	O
.	O
</s>
<s>
The	O
performance	O
of	O
a	O
hash	B-Algorithm
table	I-Algorithm
is	O
dependent	O
on	O
the	O
hash	B-Error_Name
function	I-Error_Name
's	O
ability	O
in	O
generating	O
quasi-random	O
numbers	O
(	O
)	O
for	O
entries	O
in	O
the	O
hash	B-Algorithm
table	I-Algorithm
where	O
,	O
and	O
denotes	O
the	O
key	O
,	O
number	O
of	O
buckets	O
and	O
the	O
hash	B-Error_Name
function	I-Error_Name
such	O
that	O
.	O
</s>
<s>
If	O
the	O
hash	B-Error_Name
function	I-Error_Name
generates	O
the	O
same	O
for	O
distinct	O
keys	B-Application
(	O
)	O
,	O
this	O
results	O
in	O
collision	O
,	O
which	O
is	O
dealt	O
with	O
in	O
a	O
variety	O
of	O
ways	O
.	O
</s>
<s>
The	O
constant	O
time	O
complexity	O
(	O
)	O
of	O
the	O
operation	O
in	O
a	O
hash	B-Algorithm
table	I-Algorithm
is	O
presupposed	O
on	O
the	O
condition	O
that	O
the	O
hash	B-Error_Name
function	I-Error_Name
does	O
n't	O
generate	O
colliding	O
indices	O
;	O
thus	O
,	O
the	O
performance	O
of	O
the	O
hash	B-Algorithm
table	I-Algorithm
is	O
directly	O
proportional	O
to	O
the	O
chosen	O
hash	B-Error_Name
function	I-Error_Name
's	O
ability	O
to	O
disperse	O
the	O
indices	O
.	O
</s>
<s>
However	O
,	O
construction	O
of	O
such	O
a	O
hash	B-Error_Name
function	I-Error_Name
is	O
practically	O
infeasible	O
,	O
that	O
being	O
so	O
,	O
implementations	O
depend	O
on	O
case-specific	B-Architecture
collision	O
resolution	O
techniques	O
in	O
achieving	O
higher	O
performance	O
.	O
</s>
<s>
Hash	B-Algorithm
tables	I-Algorithm
are	O
commonly	O
used	O
to	O
implement	O
many	O
types	O
of	O
in-memory	O
tables	O
.	O
</s>
<s>
They	O
are	O
used	O
to	O
implement	O
associative	B-Application
arrays	I-Application
.	O
</s>
<s>
Hash	B-Algorithm
tables	I-Algorithm
may	O
also	O
be	O
used	O
as	O
disk-based	O
data	B-General_Concept
structures	I-General_Concept
and	O
database	B-Data_Structure
indices	I-Data_Structure
(	O
such	O
as	O
in	O
dbm	B-General_Concept
)	O
although	O
B-trees	B-Architecture
are	O
more	O
popular	O
in	O
these	O
applications	O
.	O
</s>
<s>
Hash	B-Algorithm
tables	I-Algorithm
can	O
be	O
used	O
to	O
implement	O
caches	B-General_Concept
,	O
auxiliary	O
data	O
tables	O
that	O
are	O
used	O
to	O
speed	O
up	O
the	O
access	O
to	O
data	O
that	O
is	O
primarily	O
stored	O
in	O
slower	O
media	O
.	O
</s>
<s>
In	O
this	O
application	O
,	O
hash	B-Algorithm
collisions	I-Algorithm
can	O
be	O
handled	O
by	O
discarding	O
one	O
of	O
the	O
two	O
colliding	O
entries	O
—	O
usually	O
erasing	O
the	O
old	O
item	O
that	O
is	O
currently	O
stored	O
in	O
the	O
table	B-Data_Structure
and	O
overwriting	O
it	O
with	O
the	O
new	O
item	O
,	O
so	O
every	O
item	O
in	O
the	O
table	B-Data_Structure
has	O
a	O
unique	O
hash	B-Error_Name
value	I-Error_Name
.	O
</s>
<s>
Hash	B-Algorithm
tables	I-Algorithm
can	O
be	O
used	O
in	O
the	O
implementation	O
of	O
set	O
data	B-General_Concept
structure	I-General_Concept
,	O
which	O
can	O
store	O
unique	O
values	O
without	O
any	O
particular	O
order	O
;	O
set	O
is	O
typically	O
used	O
in	O
testing	O
the	O
membership	O
of	O
a	O
value	O
in	O
the	O
collection	O
,	O
rather	O
than	O
element	O
retrieval	O
.	O
</s>
<s>
A	O
transposition	B-General_Concept
table	I-General_Concept
to	O
a	O
complex	O
Hash	B-Algorithm
Table	I-Algorithm
which	O
stores	O
information	O
about	O
each	O
section	O
that	O
has	O
been	O
searched	O
.	O
</s>
<s>
Many	O
programming	O
languages	O
provide	O
hash	B-Algorithm
table	I-Algorithm
functionality	O
,	O
either	O
as	O
built-in	O
associative	B-Application
arrays	I-Application
or	O
as	O
standard	B-Library
library	I-Library
modules	O
.	O
</s>
<s>
In	O
JavaScript	B-Language
,	O
every	O
value	O
except	O
for	O
7	O
"	O
primitive	O
"	O
data	O
types	O
is	O
called	O
an	O
"	O
object	O
"	O
,	O
which	O
uses	O
either	O
integers	O
,	O
strings	O
,	O
or	O
guaranteed-unique	O
"	O
symbol	O
"	O
primitive	O
values	O
as	O
keys	B-Application
for	O
a	O
hash	B-Language
map	I-Language
.	O
</s>
<s>
ECMAScript	O
6	O
also	O
added	O
Map	O
and	O
Set	O
data	B-General_Concept
structures	I-General_Concept
.	O
</s>
<s>
C++11	B-Language
includes	O
unordered_map	B-Language
in	O
its	O
standard	B-Library
library	I-Library
for	O
storing	O
keys	B-Application
and	O
values	O
of	O
arbitrary	O
types	O
.	O
</s>
<s>
Go	O
's	O
built-in	O
map	O
implements	O
a	O
hash	B-Algorithm
table	I-Algorithm
in	O
the	O
form	O
of	O
a	O
type	O
.	O
</s>
<s>
Java	B-Language
programming	I-Language
language	I-Language
includes	O
the	O
HashSet	O
,	O
HashMap	B-Algorithm
,	O
LinkedHashSet	O
,	O
and	O
LinkedHashMap	O
generic	B-Language
collections	O
.	O
</s>
<s>
Python	B-Language
's	O
built-in	O
dict	O
implements	O
a	O
hash	B-Algorithm
table	I-Algorithm
in	O
the	O
form	O
of	O
a	O
type	O
.	O
</s>
<s>
Ruby	B-Language
's	O
built-in	O
Hash	B-Error_Name
uses	O
the	O
open	B-Algorithm
addressing	I-Algorithm
model	O
from	O
Ruby	B-Language
2.4	O
onwards	O
.	O
</s>
<s>
Rust	B-Application
programming	I-Application
language	I-Application
includes	O
HashMap	B-Algorithm
,	O
HashSet	O
as	O
part	O
of	O
the	O
Rust	B-Application
Standard	B-Library
Library	I-Library
.	O
</s>
