SlideShare a Scribd company logo
HASH MAP
Hash
Table
KEY VALUE
Key Value Pair
Key VALUE
pierre 01.42.78.96.12
paul 03.67.90.67.00
françois 01.45.87.90.45
mohamed 04.88.8945.29
khaled 06.98.56.22.48
laila 01.23.45.67.89
alex 34.56.15.27.78.
claire 34.56.73.45.67
philippe 02.34.26.48.26.
Hash()
françois 01.45.87.90.45
Phone Numbers list example
Key VALUE
pierre 01.42.78.96.12
paul 03.67.90.67.00
françois 01.45.87.90.45
mohamed 04.88.8945.29
khaled 06.98.56.22.48
laila 01.23.45.67.89
alex 34.56.15.27.78.
claire 34.56.73.45.67
philippe 02.34.26.48.26.
Hash()
françois 01.45.87.90.45
Phone Numbers list example
Key Value
Employees File SSN : Social Security Number
125675798988090
000000000000000
999999999999999
Social Security Number = address
Employees File SSN : Social Security Number
125675798988090
000000000000000
999999999999999
Social Security Number = address
steve
mike
john
bob
max
edward
John SSN : 125675798988090
Employees File SSN : Social Security Number
125675798988090
000000000000000
999999999999999
Social Security Number = address
steve
mike
john
bob
max
edward
Requires Memory size :
999999999999999
= 1E+15 = 1 petaoctet (Po)
John SSN : 125675798988090
Employees File SSN : Social Security Number
125675798988090
000000000000000
999999999999999
N element Array
SSN
00
99
steve
mike
john
bob
max
edward
125675798988090
100 employees
Employees File SSN : Social Security Number
125675798988090
000000000000000
999999999999999
N element Array
SSN
00
99
steve
mike
john
bob
max
edward
steve
bob
john
mike
edward125675798988090
Employees File SSN : Social Security Number
125675798988090
000000000000000
999999999999999
N element Array
SSN
00
99
steve
mike
john
bob
max
edward
steve
bob
john
mike
edward125675798988090
Employees File SSN : Social Security Number
125675798988090
000000000000000
999999999999999
steve
N element Array
00
99
KEY
hash
bob
john
mike
edward
value
addresses
steve
mike
john
bob
max
edward
Hashing
125675798988090000000000000000 999999999999999
00 99
Hashing
125675798988090000000000000000 999999999999999
00 99
Hashing
125675798988090000000000000000 999999999999999
00 99
Hashing
Employees File
SSN : Social Security Number
125675798988090
000000000000000
999999999999999
john
N element Array
00
99
KEY
hash
bob
mike
edward
value
addresses
steve
mike
john
bob
max
edward
Key
space
Address
space
Key space to Address space
mapping
125675798988090
000000000000000
999999999999999
Address
space
Key
space
00
99
Key space to Address space
mapping
125675798988090
000000000000000
999999999999999
Address
space
Key
space
Index
00
99
Buckets principle
Hash Function
 The hash function is used to transform the key into the
index (the hash) of an array element (the slot or bucket)
where the corresponding value is to be stored and sought.
KEY HASH
index
Value
Bucket (slot)
Hash table
 hash table is an array-based data structure.
129007
926647
975378
269908
Fred
Steve
Richard
Robert
Key Value
0
1
3
4
5
2
index
SSN
Hash table
 hash function is used to convert the key into
the index of an array element, where
associated value is to be seek.
129007
926647
975378
269908
Fred
Steve
Richard
Robert
Key Value
h(129007)
h(129007)
h(975378)
h(269908)
0
1
3
4
5
2
index
SSN
buckets
Collision
 If the hash function returns a slot that is
already occupied there is a collision
129007
975378
269908
Fred
Richard
Robert
Key Value
H(129007)
H(975378)
H(269908)
H(926647)
0
1
3
4
2
0
1
3
4
5
2
hash clustering
 When the distribution of keys into buckets is not random,
we say that the hash table exhibits clustering.
129007
975378
269908
Fred
Richard
Robert
Key Value
H(697803)
H(975378)
H(269908)
H(926647)
H(168477)
H(129007)
6
7
Hash function
Good Hash function provides uniform
distribution of hash values.
Poor hash function will cause collisions and
hash cluster.
Hash Distribution
Value # Hash
0 2
1 2
2 2
3 2
4 0
5 0
6 0
7 0
8 0
9 0
10 1
0
1
2
3
1 2 3 4 5 6 7 8 9 10 11
# Hash
Hash Distribution
0
1
2
1 2 3 4 5 6 7 8 9 10 11
# Hash
# Hash
Value # Hash
0 1
1 1
2 1
3 1
4 1
5 1
6 1
7 1
8 1
9 1
10 1
Hash Distribution
Value # Hash
0 0
1 0
2 0
3 1
4 3
5 5
6 3
7 1
8 0
9 0
10 0
0
1
2
3
4
5
6
1 2 3 4 5 6 7 8 9 10 11
# Hash
# Hash
Hash function toy implementation :
Modulo N R CAR(R) mod (11)
A 65 10
B 66 0
C 67 1
D 68 2
E 69 3
F 70 4
G 71 5
H 72 6
I 73 7
J 74 8
K 75 9
L 76 10
M 77 0
N 78 1
O 79 2
P 80 3
Q 81 4
R 82 5
S 83 6
T 84 7
U 85 8
V 86 9
W 87 10
X 88 0
Y 89 1
Z 90 2
26 => 11
Modulo N Hash Distribution
Load Factor
Key Value
0 B 0
1 C 4
2 O 1
3 E 2
4 P 3
5 X 6
6 N 7
7 D 8
8 M 9
9
10 L 5
Key Value
0 B 0
1 C 4
2 O 1
3 E 2
4 P 3
5 X 6
6 N 7
7 D 8
8 M 9
9
10 L S
11
12
13
14
15
16
17
18
19
20
21
# elements in the hash Table
size of the hash table
48 %
91 %
Collision handling strategies
Closed addressing (open hashing).
Open addressing (closed hashing).
0
1
3
4
5
2
129007
975378
269908
Fred
Richard
Robert
Key Value
H(697803)
H(975378)
H(269908)
H(926647)
H(168477)
H(129007)
6
7
Open addressing (closed hashing).
 When there is a collision, "Probe" the array to
find an empty slot after the occupied slot.
129007
926647
975378
269908
Fred
Steve
Richard
Robert
Key Value
H(697803)
H(975378)
H(269908)
H(926647)
168477 Phil
697803 Greg
H(168477)
H(129007)
Closed addressing (open hashing).
Each slot of the hash table contains a link to
another data structure.
129007
926647
975378
269908
Fred
Steve
168477 Phil
697803 Greg
Key
129007
975378 Richard
269908 Robert
Linear Hashing
• Linear Hashing
– Re-hash : hi (x) = (h(x) + i) mod B
• Stepsize : i
• i = 1,2,3, …
• Quadratic Hashing
– Re-hash : hi (x) = (h (x) + i ²) mod B
• Stepsize : i2
• i2 = 1,4,9,…
• Double Hashing
– Re-hash : hi (x) = (h(x) + i g (x)) mod B
• Stepsize : g(x)
Toy implementation example : R
Attribut ARelation R
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
modulo
Char Ascii Code
Value Key
RID R CAR(R) mod (11)
0 B 66 0
1 O 79 2
2 E 69 3
3 P 80 3
4 C 67 1
5 L 76 10
6 X 88 0
7 N 78 1
8 D 68 2
9 M 77 0
Class HashLinearProbing
 Hash(key)  returns hash
 Put (key, value)  inserts key value pair
 Get (key)  gets key value
 Remove (key)  removes key preserving bucket
structure.
Class HashMap JSE 1.4
Object get(Object key)
Returns the value to which the specified key is
mapped in this identity hash map, or null if the map
contains no mapping for this key.
Object put(Object key, Object value)
Associates the specified value with the specified key
in this map.
Object remove(Object key)
Removes the mapping for this key from this map if
present
Linear Probing toy implementation
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
KEY VAL
0
1
2
3
4
5
6
7
8
9
10
M
N
Relation Data Structure Implementation
Logical
Physical
Linear Probing toy implementation
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
KEY VAL
0
1
2
3
4
5
6
7
8
9
10
M
N
M > N
Empty Slot is
Search Stop Condition
Linear Probing toy implementation
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
KEY VAL
0
1
2
3
4
5
6
7
8
9
10
11
10
M > N
Empty Slot is
Search Stop Condition
Linear Probing
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
X 6
O 1
E 2
P 3
N 7
V 4
L 5
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Hash(key)
First
Empty
Slot ?
Put(N,7)
%M
Empty Slot is
Search Place Stop Condition
Linear Probing
Hash(key)
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
X 6
O 1
E 2
P 3
N 7
K 8
M 9
V 4
L 5
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Car Y = 89
Y mod 11 = 1
Hash(key)
Get(Y)
Y ?
Empty
Stop
Return (-1) Empty Slot is
Search Stop Condition
Linear Probing toy implementation
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
KEY VAL
0
1
2
3
4
5
6
7
8
9
10
11
10
M > N
Empty Slot is
Search Stop Condition
At least one empty slot
M – N = 1
Linear Probing
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
KEY VAL
0
1
2
3
4
5
6
7
8
9
10
M
N
Linear Probing
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
Example Relation
Implementation
Linear Probing
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
Hash(key) = CAR(R) Mod (M)
M = 11
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Linear Probing
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
Hash(key)
Put(B,0)
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Linear Probing
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
O 1
Hash(key)
Put(O,1)
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Linear Probing
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
O 1
E 2
Hash(key)
Put(E,2)
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Linear Probing
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
O 1
E 2
P 3
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Hash(key)
First
Empty
Slot ?
Put(P,3)
Linear Probing
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
O 1
E 2
P 3
V 4
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Hash(key)
Put(V,4)
Linear Probing
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
O 1
E 2
P 3
V 4
L 5
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Hash(key)
Put(L,5)
Linear Probing
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
X 6
O 1
E 2
P 3
V 4
L 5
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Hash(key)
First
Empty
Slot ?
Put(X,6)
%M
Linear Probing
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
X 6
O 1
E 2
P 3
N 7
V 4
L 5
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Hash(key)
First
Empty
Slot ?
Put(N,7)
%M
Linear Probing
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Hash(key)
First
Empty
Slot ?
Put(K,8)
%M
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
X 6
O 1
E 2
P 3
N 7
K 8
V 4
L 5
Linear Probing
Hash(key)
Put(M,9)
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
X 6
O 1
E 2
P 3
N 7
K 8
M 9
V 4
L 5
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
First
Empty
Slot ?
0
2
3
3
9
10
0
1
9
0
Linear Probing
Hash(key)
Put(M,9)
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
X 6
O 1
E 2
P 3
N 7
K 8
M 9
V 4
L 5
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Linear Probing
Hash(key)
Put(M,9)
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
X 6
O 1
E 2
P 3
N 7
K 8
M 9
V 4
L 5
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Implementation of function Hash(Key)
 In Java : Key % M
 Specific case of Java char : in Java char are integer (Byte).
 char: The char data type is a single 16-bit Unicode character. It has a minimum
value of 'u0000' (or 0) and a maximum value of 'uffff' (or 65,535 inclusive).
 Null char is 0 (zero).
 Default value for char is 0, or u0000.
Hash (Key) { Return Key Modulo M }
http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html
Bucket Table Implementation
KEY VAL
char keys Array [M] int values Array [M]
Put(key, value) simplified algo
M = # bucket entries
index = hash (key)
While Key [index) != empty
index = (index + 1) % M
End while
Key [index] = key
Values [index] = value
Get(Key)
 Get existing key
 Get non inserted key
Linear Probing
Hash(key)
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
X 6
O 1
E 2
P 3
N 7
K 8
M 9
V 4
L 5
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Hash(key)Hash(key)
Get(B)
B,0
B ?
Linear Probing
Hash(key)
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
X 6
O 1
E 2
P 3
N 7
K 8
M 9
V 4
L 5
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Hash(key)
Get(M)
M ?
M, 9
Linear Probing
Hash(key)
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
X 6
O 1
E 2
P 3
N 7
K 8
M 9
V 4
L 5
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Hash(key)
K ?
K,8
Get(K)
Linear Probing
Hash(key)
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
X 6
O 1
E 2
P 3
N 7
K 8
M 9
V 4
L 5
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Car Y = 89
Y mod 11 = 1
Hash(key)
Get(Y)
Y ?
Empty
Stop
Return (-1)
Get(key)
M = # buckets
index = hash (key)
valueToReturn = -1 // value to return if the key is not in the map
While Key [index] != key and Key [index] != empty
index = (index + 1) % M
End while
If (Key [index] = key) valueToReturn = Values [index]
Return valueToReturn
Remove (Key)
 Remove (M)
 Remove (N) : rehash end of the cluster.
 Remove (L) : rehash end of the cluster.
Linear Probing
Hash(key)
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
X 6
O 1
E 2
P 3
N 7
K 8
M 9
V 4
L 5
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Hash(key)
Remove (M)
K(0) != M
Blank
Scan for M
Linear Probing
Hash(key)
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
X 6
O 1
E 2
P 3
N 7
K 8
V 4
L 5
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Hash(key)
Remove (M)
K(0) != M
Blank
Scan for M
Linear Probing
Hash(key)
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
X 6
O 1
E 2
P 3
N 7
K 8
M 9
V 4
L 5
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Hash(key)
Remove (N)
K(1) != N
Blank and rehash
End of cluster
Scan for N
Linear Probing
Hash(key)
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
X 6
O 1
E 2
P 3
N 7
K 8
M 9
V 4
L 5
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Cluster
Remove (N)
K(1) != N
Blank and rehash
End of cluster
Scan for N
Linear Probing
Hash(key)
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
X 6
O 1
E 2
P 3
K 8
M 9
V 4
L 5
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Remove (N)
K(1) != N
Blank and rehash
End of cluster
Scan for N
EOf
cluster
Linear Probing
Hash(key)
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
X 6
O 1
E 2
P 3
K 8
M 9
V 4
L 5
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Remove (N)
K(1) != N
Blank and rehash
End of cluster
Scan for N
EOf
cluster
Blank Key(6) , Val(6)
put(K,8)
Linear Probing
Hash(key)
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
X 6
O 1
E 2
P 3
M 9
V 4
L 5
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Remove (N)
K(1) != N
Blank and rehash
End of cluster
Scan for N
EOf
cluster
Blank Key(6) , Val(6)
put(K,8)
Linear Probing
Hash(key)
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
X 6
O 1
E 2
P 3
M 9
V 4
L 5
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Remove (N)
K(1) != N
Blank and rehash
End of cluster
Scan for N
Blank Key(6) , Val(6)
put(K,8)
Linear Probing
Hash(key)
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
X 6
O 1
E 2
P 3
M 9
V 4
L 5
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Remove (N)
K(1) != N
Blank and rehash
End of cluster
Scan for N
Blank Key(6), Val(6)
put(K,8)
Linear Probing
Hash(key)
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
X 6
O 1
E 2
P 3
K 8
M 9
V 4
L 5
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Remove (N)
K(1) != N
Blank and rehash
End of cluster
Scan for N
Blank Key(7) ,Val(7)
put(K,8)
Linear Probing
Hash(key)
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
X 6
O 1
E 2
P 3
K 8
M 9
V 4
L 5
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Remove (N)
K(1) != N
Blank and rehash
End of cluster
Scan for N
Blank Key(7) ,Val(7)
put(K,8)
Linear Probing
Hash(key)
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
X 6
O 1
E 2
P 3
K 8
V 4
L 5
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Remove (N)
K(1) != N
Blank and rehash
End of cluster
Scan for N
Blank Key(7) , Val(7)
put(M,9)
Linear Probing
Hash(key)
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
X 6
O 1
E 2
P 3
K 8
V 4
L 5
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Remove (N)
K(1) != N
Blank and rehash
End of cluster
Scan for N
Blank Key(7) , Val(7)
put(M,9)
First
Empty
Slot ?
Linear Probing
Hash(key)
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
X 6
O 1
E 2
P 3
K 8
9
V 4
L 5
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Remove (N)
K(1) != N
Blank and rehash
End of cluster
Scan for N
Blank Key(7) , Val(7)
put(M,9)
First
Empty
Slot ?
M
Linear Probing
Hash(key)
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
X 6
O 1
E 2
P 3
N 7
K 8
M 9
V 4
L 5
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Remove (L)
Linear Probing
Hash(key)
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
X 6
O 1
E 2
P 3
N 7
K 8
M 9
V 4
L 5
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
K(10) = L blank
Remove (L)
Blank and rehash
End of cluster
Linear Probing
Hash(key)
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
X 6
O 1
E 2
P 3
N 7
K 8
M 9
V 4
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
K(10) = L blank
Remove (L)
Blank and rehash
End of cluster
Linear Probing
Hash(key)
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
X 6
O 1
E 2
P 3
N 7
K 8
M 9
V 4
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
K(10) = L blank
Remove (L)
Blank and rehash
End of cluster
EOf
cluster
Linear Probing
Hash(key)
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
X 6
O 1
E 2
P 3
N 7
K 8
M 9
V 4
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Remove (L)
Blank and rehash
End of cluster
EOf
cluster
Blank Key(0) , Val(0)
put(B,0)
Linear Probing
Hash(key)
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
X 6
O 1
E 2
P 3
N 7
K 8
M 9
V 4
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Remove (L)
Blank and rehash
End of cluster
EOf
cluster
Blank Key(1) , Val(1)
put(X,6)
Linear Probing
Hash(key)
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
X 6
O 1
E 2
P 3
N 7
K 8
M 9
V 4
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Remove (L)
Blank and rehash
End of cluster
EOf
cluster
Blank Key(2) , Val(2)
put(O,1)
Linear Probing
Hash(key)
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
X 6
O 1
E 2
P 3
N 7
K 8
M 9
V 4
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Remove (L)
Blank and rehash
End of cluster
EOf
cluster
Blank Key(3) , Val(3)
put(E,2)
Linear Probing
Hash(key)
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
X 6
O 1
E 2
P 3
N 7
K 8
M 9
V 4
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Remove (L)
Blank and rehash
End of cluster
EOf
cluster
Blank Key(4), Val(4)
put(P,3)
Linear Probing
Hash(key)
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
X 6
O 1
E 2
P 3
N 7
K 8
M 9
V 4
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Remove (L)
Blank and rehash
End of cluster
EOf
cluster
Blank Key(5), Val(5)
put(N,7)
Linear Probing
Hash(key)
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
X 6
O 1
E 2
P 3
N 7
K 8
M 9
V 4
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Remove (L)
Blank and rehash
End of cluster
EOf
cluster
Blank Key(6) , Val(6)
put(K,8)
Linear Probing
Hash(key)
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
X 6
O 1
E 2
P 3
N 7
M 9
V 4
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Remove (L)
Blank and rehash
End of cluster
EOf
cluster
Blank Key(6) , Val(6)
put(K,8)
Linear Probing
Hash(key)
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
X 6
O 1
E 2
P 3
N 7
M 9
V 4
K 8
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Remove (L)
Blank and rehash
End of cluster
EOf
cluster
Blank Key(6) , Val(6)
put(K,8)
Linear Probing
Hash(key)
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
X 6
O 1
E 2
P 3
N 7
M 9
V 4
K 8
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Remove (L)
Blank and rehash
End of cluster
EOf
cluster
Blank Key(7) , Val(7)
put(M,9)
Linear Probing
Hash(key)
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
X 6
O 1
E 2
P 3
N 7
M 9
V 4
K 8
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Remove (L)
Blank and rehash
End of cluster
EOf
cluster
Blank Key(7) , Val(7)
put(M,9)
Linear Probing
Hash(key)
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
X 6
O 1
E 2
P 3
N 7
M 9
V 4
K 8
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Remove (L)
Blank and rehash
End of cluster
EOf
cluster
Blank Key(7) , Val(7)
put(M,9)
Linear Probing
Hash(key)
KEY VAL
B 00
1
2
3
4
5
6
7
8
9
10
X 6
O 1
E 2
P 3
N 7
M 9
V 4
K 8
Value Key
RID R
0 B
1 O
2 E
3 P
4 V
5 L
6 X
7 N
8 K
9 M
0
2
3
3
9
10
0
1
9
0
Remove (L)
Blank and rehash
End of cluster
EOf
cluster
Blank Key(7) , Val(7)
put(M,9)
Remove (key) simplified algo
M = # buckets
index = hash (key)
While Key [index) != key and Key [index) != empty
index = (index + 1) % M
End while
Key [index] = 0, Value [index] = 0
// rehash
index = (index + 1) % M
While Key [index) != empty
savedKey = Key [index], savedValue = Value [index]
Key [index] = 0 Value [index] = 0
Put ( savedKey , savedValue )
index = (index + 1) % M
End while
The End

More Related Content

What's hot

Python programming : List and tuples
Python programming : List and tuplesPython programming : List and tuples
Python programming : List and tuples
Emertxe Information Technologies Pvt Ltd
 
sets and maps
 sets and maps sets and maps
sets and maps
Rajkattamuri
 
Stack using Linked List
Stack using Linked ListStack using Linked List
Stack using Linked List
Sayantan Sur
 
Java Stack Data Structure.pptx
Java Stack Data Structure.pptxJava Stack Data Structure.pptx
Java Stack Data Structure.pptx
vishal choudhary
 
Html5 Basics
Html5 BasicsHtml5 Basics
Html5 Basics
Pankaj Bajaj
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
Taha Malampatti
 
Data structure and algorithm using java
Data structure and algorithm using javaData structure and algorithm using java
Data structure and algorithm using java
Narayan Sau
 
MongoDB Aggregation Framework
MongoDB Aggregation FrameworkMongoDB Aggregation Framework
MongoDB Aggregation Framework
Caserta
 
PHP FUNCTIONS
PHP FUNCTIONSPHP FUNCTIONS
PHP FUNCTIONS
Zeeshan Ahmed
 
Linear and Binary search
Linear and Binary searchLinear and Binary search
Linear and Binary search
Nisha Soms
 
MySQL Functions
MySQL FunctionsMySQL Functions
MySQL Functions
Compare Infobase Limited
 
Data structures using c
Data structures using cData structures using c
Data structures using c
Prof. Dr. K. Adisesha
 
Quick sort-Data Structure
Quick sort-Data StructureQuick sort-Data Structure
Quick sort-Data Structure
Jeanie Arnoco
 
Ppt on this and super keyword
Ppt on this and super keywordPpt on this and super keyword
Ppt on this and super keyword
tanu_jaswal
 
Java Collections
Java  Collections Java  Collections
Hashing In Data Structure
Hashing In Data Structure Hashing In Data Structure
Hashing In Data Structure
Meghaj Mallick
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
slire
 
Java packages
Java packagesJava packages
Java packages
Shreyans Pathak
 
Java RMI
Java RMIJava RMI
Java RMI
Sunil OS
 
Jsp/Servlet
Jsp/ServletJsp/Servlet
Jsp/Servlet
Sunil OS
 

What's hot (20)

Python programming : List and tuples
Python programming : List and tuplesPython programming : List and tuples
Python programming : List and tuples
 
sets and maps
 sets and maps sets and maps
sets and maps
 
Stack using Linked List
Stack using Linked ListStack using Linked List
Stack using Linked List
 
Java Stack Data Structure.pptx
Java Stack Data Structure.pptxJava Stack Data Structure.pptx
Java Stack Data Structure.pptx
 
Html5 Basics
Html5 BasicsHtml5 Basics
Html5 Basics
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
Data structure and algorithm using java
Data structure and algorithm using javaData structure and algorithm using java
Data structure and algorithm using java
 
MongoDB Aggregation Framework
MongoDB Aggregation FrameworkMongoDB Aggregation Framework
MongoDB Aggregation Framework
 
PHP FUNCTIONS
PHP FUNCTIONSPHP FUNCTIONS
PHP FUNCTIONS
 
Linear and Binary search
Linear and Binary searchLinear and Binary search
Linear and Binary search
 
MySQL Functions
MySQL FunctionsMySQL Functions
MySQL Functions
 
Data structures using c
Data structures using cData structures using c
Data structures using c
 
Quick sort-Data Structure
Quick sort-Data StructureQuick sort-Data Structure
Quick sort-Data Structure
 
Ppt on this and super keyword
Ppt on this and super keywordPpt on this and super keyword
Ppt on this and super keyword
 
Java Collections
Java  Collections Java  Collections
Java Collections
 
Hashing In Data Structure
Hashing In Data Structure Hashing In Data Structure
Hashing In Data Structure
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
 
Java packages
Java packagesJava packages
Java packages
 
Java RMI
Java RMIJava RMI
Java RMI
 
Jsp/Servlet
Jsp/ServletJsp/Servlet
Jsp/Servlet
 

Viewers also liked

Spring IOC and DAO
Spring IOC and DAOSpring IOC and DAO
Spring IOC and DAO
AnushaNaidu
 
Cassandra Community Webinar | Cassandra 2.0 - Better, Faster, Stronger
Cassandra Community Webinar | Cassandra 2.0 - Better, Faster, StrongerCassandra Community Webinar | Cassandra 2.0 - Better, Faster, Stronger
Cassandra Community Webinar | Cassandra 2.0 - Better, Faster, Stronger
DataStax
 
How Twitter Works (Arsen Kostenko Technology Stream)
How Twitter Works (Arsen Kostenko Technology Stream) How Twitter Works (Arsen Kostenko Technology Stream)
How Twitter Works (Arsen Kostenko Technology Stream)
IT Arena
 
Hash table
Hash tableHash table
Hash table
Rajendran
 
Dependency Injection and Inversion Of Control
Dependency Injection and Inversion Of ControlDependency Injection and Inversion Of Control
Dependency Injection and Inversion Of Control
Simone Busoli
 
Metrics at Scale @ UBER (Mantas Klasavicius Technology Stream)
Metrics at Scale @ UBER (Mantas Klasavicius Technology Stream)Metrics at Scale @ UBER (Mantas Klasavicius Technology Stream)
Metrics at Scale @ UBER (Mantas Klasavicius Technology Stream)
IT Arena
 
Dependency injection - the right way
Dependency injection - the right wayDependency injection - the right way
Dependency injection - the right way
Thibaud Desodt
 
Inversion of Control - Introduction and Best Practice
Inversion of Control - Introduction and Best PracticeInversion of Control - Introduction and Best Practice
Inversion of Control - Introduction and Best Practice
Lars-Erik Kindblad
 
Amazon interview questions
Amazon interview questionsAmazon interview questions
Amazon interview questions
Sumit Arora
 
System analysis and design
System analysis and design System analysis and design
System analysis and design
Razan Al Ryalat
 
Introduction to Graph Databases
Introduction to Graph DatabasesIntroduction to Graph Databases
Introduction to Graph Databases
Max De Marzi
 
System Design and Analysis 1
System Design and Analysis 1System Design and Analysis 1
System Design and Analysis 1
Boeun Tim
 
Neo4j - 5 cool graph examples
Neo4j - 5 cool graph examplesNeo4j - 5 cool graph examples
Neo4j - 5 cool graph examples
Peter Neubauer
 
Graph database Use Cases
Graph database Use CasesGraph database Use Cases
Graph database Use Cases
Max De Marzi
 
System Analysis and Design
System Analysis and DesignSystem Analysis and Design
System Analysis and Design
Aamir Abbas
 
Data Modeling with Neo4j
Data Modeling with Neo4jData Modeling with Neo4j
Data Modeling with Neo4j
Neo4j
 

Viewers also liked (16)

Spring IOC and DAO
Spring IOC and DAOSpring IOC and DAO
Spring IOC and DAO
 
Cassandra Community Webinar | Cassandra 2.0 - Better, Faster, Stronger
Cassandra Community Webinar | Cassandra 2.0 - Better, Faster, StrongerCassandra Community Webinar | Cassandra 2.0 - Better, Faster, Stronger
Cassandra Community Webinar | Cassandra 2.0 - Better, Faster, Stronger
 
How Twitter Works (Arsen Kostenko Technology Stream)
How Twitter Works (Arsen Kostenko Technology Stream) How Twitter Works (Arsen Kostenko Technology Stream)
How Twitter Works (Arsen Kostenko Technology Stream)
 
Hash table
Hash tableHash table
Hash table
 
Dependency Injection and Inversion Of Control
Dependency Injection and Inversion Of ControlDependency Injection and Inversion Of Control
Dependency Injection and Inversion Of Control
 
Metrics at Scale @ UBER (Mantas Klasavicius Technology Stream)
Metrics at Scale @ UBER (Mantas Klasavicius Technology Stream)Metrics at Scale @ UBER (Mantas Klasavicius Technology Stream)
Metrics at Scale @ UBER (Mantas Klasavicius Technology Stream)
 
Dependency injection - the right way
Dependency injection - the right wayDependency injection - the right way
Dependency injection - the right way
 
Inversion of Control - Introduction and Best Practice
Inversion of Control - Introduction and Best PracticeInversion of Control - Introduction and Best Practice
Inversion of Control - Introduction and Best Practice
 
Amazon interview questions
Amazon interview questionsAmazon interview questions
Amazon interview questions
 
System analysis and design
System analysis and design System analysis and design
System analysis and design
 
Introduction to Graph Databases
Introduction to Graph DatabasesIntroduction to Graph Databases
Introduction to Graph Databases
 
System Design and Analysis 1
System Design and Analysis 1System Design and Analysis 1
System Design and Analysis 1
 
Neo4j - 5 cool graph examples
Neo4j - 5 cool graph examplesNeo4j - 5 cool graph examples
Neo4j - 5 cool graph examples
 
Graph database Use Cases
Graph database Use CasesGraph database Use Cases
Graph database Use Cases
 
System Analysis and Design
System Analysis and DesignSystem Analysis and Design
System Analysis and Design
 
Data Modeling with Neo4j
Data Modeling with Neo4jData Modeling with Neo4j
Data Modeling with Neo4j
 

Similar to Hash map

Lisp tutorial
Lisp tutorialLisp tutorial
Lisp tutorial
Nilt1234
 
Slr parser
Slr parserSlr parser
AES Encryption
AES EncryptionAES Encryption
AES Encryption
Rahul Marwaha
 
A successful maximum likelihood parameter estimation in skewed distributions ...
A successful maximum likelihood parameter estimation in skewed distributions ...A successful maximum likelihood parameter estimation in skewed distributions ...
A successful maximum likelihood parameter estimation in skewed distributions ...
Hideo Hirose
 
4.4 hashing02
4.4 hashing024.4 hashing02
4.4 hashing02
Krish_ver2
 
Data Structures- Hashing
Data Structures- Hashing Data Structures- Hashing
Data Structures- Hashing
hemalatha athinarayanan
 
Hashing
HashingHashing
Hashing
Ghaffar Khan
 
Presentation1
Presentation1Presentation1
Presentation1
Saurabh Mishra
 
[PyCon KR 2019] Pickle & Custom Binary Serializer
[PyCon KR 2019] Pickle & Custom Binary Serializer[PyCon KR 2019] Pickle & Custom Binary Serializer
[PyCon KR 2019] Pickle & Custom Binary Serializer
Young Seok Kim
 
cryptography2 WHICH IS VERY IMPOTRANT.pdf
cryptography2 WHICH IS VERY IMPOTRANT.pdfcryptography2 WHICH IS VERY IMPOTRANT.pdf
cryptography2 WHICH IS VERY IMPOTRANT.pdf
gadisagemechu1
 
computer notes - Data Structures - 32
computer notes - Data Structures - 32computer notes - Data Structures - 32
computer notes - Data Structures - 32
ecomputernotes
 

Similar to Hash map (11)

Lisp tutorial
Lisp tutorialLisp tutorial
Lisp tutorial
 
Slr parser
Slr parserSlr parser
Slr parser
 
AES Encryption
AES EncryptionAES Encryption
AES Encryption
 
A successful maximum likelihood parameter estimation in skewed distributions ...
A successful maximum likelihood parameter estimation in skewed distributions ...A successful maximum likelihood parameter estimation in skewed distributions ...
A successful maximum likelihood parameter estimation in skewed distributions ...
 
4.4 hashing02
4.4 hashing024.4 hashing02
4.4 hashing02
 
Data Structures- Hashing
Data Structures- Hashing Data Structures- Hashing
Data Structures- Hashing
 
Hashing
HashingHashing
Hashing
 
Presentation1
Presentation1Presentation1
Presentation1
 
[PyCon KR 2019] Pickle & Custom Binary Serializer
[PyCon KR 2019] Pickle & Custom Binary Serializer[PyCon KR 2019] Pickle & Custom Binary Serializer
[PyCon KR 2019] Pickle & Custom Binary Serializer
 
cryptography2 WHICH IS VERY IMPOTRANT.pdf
cryptography2 WHICH IS VERY IMPOTRANT.pdfcryptography2 WHICH IS VERY IMPOTRANT.pdf
cryptography2 WHICH IS VERY IMPOTRANT.pdf
 
computer notes - Data Structures - 32
computer notes - Data Structures - 32computer notes - Data Structures - 32
computer notes - Data Structures - 32
 

More from Emmanuel Fuchs

Distributed Object Systems
Distributed Object SystemsDistributed Object Systems
Distributed Object Systems
Emmanuel Fuchs
 
CARDAMOM_CCM_Tutorial_Draft 2004
CARDAMOM_CCM_Tutorial_Draft 2004CARDAMOM_CCM_Tutorial_Draft 2004
CARDAMOM_CCM_Tutorial_Draft 2004
Emmanuel Fuchs
 
Anootations IEEE 42010 : A Conceptual Model of Architecture Description
Anootations IEEE 42010 : A Conceptual Model of Architecture DescriptionAnootations IEEE 42010 : A Conceptual Model of Architecture Description
Anootations IEEE 42010 : A Conceptual Model of Architecture Description
Emmanuel Fuchs
 
Book Recommendations
 Book Recommendations Book Recommendations
Book Recommendations
Emmanuel Fuchs
 
PLUG : Presentation Layer Universal Generator
 PLUG : Presentation Layer Universal Generator PLUG : Presentation Layer Universal Generator
PLUG : Presentation Layer Universal Generator
Emmanuel Fuchs
 
PLUG : Presentation Layer Universal Generator
PLUG : Presentation Layer Universal GeneratorPLUG : Presentation Layer Universal Generator
PLUG : Presentation Layer Universal Generator
Emmanuel Fuchs
 
PLUG : Presentation Layer Universal Generator
 PLUG : Presentation Layer Universal Generator PLUG : Presentation Layer Universal Generator
PLUG : Presentation Layer Universal Generator
Emmanuel Fuchs
 
PLUG : Presentation Layer Universal Generator
PLUG : Presentation Layer Universal GeneratorPLUG : Presentation Layer Universal Generator
PLUG : Presentation Layer Universal Generator
Emmanuel Fuchs
 
UBSS : Unix Based System Software
UBSS : Unix Based System SoftwareUBSS : Unix Based System Software
UBSS : Unix Based System Software
Emmanuel Fuchs
 
ISORC 1999 Panel III
ISORC 1999 Panel IIIISORC 1999 Panel III
ISORC 1999 Panel III
Emmanuel Fuchs
 
ISORC’99
ISORC’99ISORC’99
ISORC’99
Emmanuel Fuchs
 
Object-Oriented Real-Time Distributed Computing, 1999. (ISORC '99)
Object-Oriented Real-Time Distributed Computing, 1999. (ISORC '99)Object-Oriented Real-Time Distributed Computing, 1999. (ISORC '99)
Object-Oriented Real-Time Distributed Computing, 1999. (ISORC '99)
Emmanuel Fuchs
 
Distributed Object Computing
Distributed Object ComputingDistributed Object Computing
Distributed Object Computing
Emmanuel Fuchs
 
ATM system history
ATM system historyATM system history
ATM system history
Emmanuel Fuchs
 
Middleware
MiddlewareMiddleware
Middleware
Emmanuel Fuchs
 
EUROCAT
EUROCATEUROCAT
Executive Summary ITEA Roadmap 2
Executive Summary ITEA Roadmap 2Executive Summary ITEA Roadmap 2
Executive Summary ITEA Roadmap 2
Emmanuel Fuchs
 
01_Program
01_Program01_Program
01_Program
Emmanuel Fuchs
 

More from Emmanuel Fuchs (20)

Distributed Object Systems
Distributed Object SystemsDistributed Object Systems
Distributed Object Systems
 
CARDAMOM_CCM_Tutorial_Draft 2004
CARDAMOM_CCM_Tutorial_Draft 2004CARDAMOM_CCM_Tutorial_Draft 2004
CARDAMOM_CCM_Tutorial_Draft 2004
 
Anootations IEEE 42010 : A Conceptual Model of Architecture Description
Anootations IEEE 42010 : A Conceptual Model of Architecture DescriptionAnootations IEEE 42010 : A Conceptual Model of Architecture Description
Anootations IEEE 42010 : A Conceptual Model of Architecture Description
 
Book Recommendations
 Book Recommendations Book Recommendations
Book Recommendations
 
PLUG : Presentation Layer Universal Generator
 PLUG : Presentation Layer Universal Generator PLUG : Presentation Layer Universal Generator
PLUG : Presentation Layer Universal Generator
 
PLUG : Presentation Layer Universal Generator
PLUG : Presentation Layer Universal GeneratorPLUG : Presentation Layer Universal Generator
PLUG : Presentation Layer Universal Generator
 
PLUG : Presentation Layer Universal Generator
 PLUG : Presentation Layer Universal Generator PLUG : Presentation Layer Universal Generator
PLUG : Presentation Layer Universal Generator
 
PLUG : Presentation Layer Universal Generator
PLUG : Presentation Layer Universal GeneratorPLUG : Presentation Layer Universal Generator
PLUG : Presentation Layer Universal Generator
 
UBSS2
UBSS2UBSS2
UBSS2
 
UBSS : Unix Based System Software
UBSS : Unix Based System SoftwareUBSS : Unix Based System Software
UBSS : Unix Based System Software
 
ISORC 1999 Panel III
ISORC 1999 Panel IIIISORC 1999 Panel III
ISORC 1999 Panel III
 
ISORC’99
ISORC’99ISORC’99
ISORC’99
 
Object-Oriented Real-Time Distributed Computing, 1999. (ISORC '99)
Object-Oriented Real-Time Distributed Computing, 1999. (ISORC '99)Object-Oriented Real-Time Distributed Computing, 1999. (ISORC '99)
Object-Oriented Real-Time Distributed Computing, 1999. (ISORC '99)
 
Distributed Object Computing
Distributed Object ComputingDistributed Object Computing
Distributed Object Computing
 
ATM system history
ATM system historyATM system history
ATM system history
 
Middleware
MiddlewareMiddleware
Middleware
 
photoISEN 1987
photoISEN 1987photoISEN 1987
photoISEN 1987
 
EUROCAT
EUROCATEUROCAT
EUROCAT
 
Executive Summary ITEA Roadmap 2
Executive Summary ITEA Roadmap 2Executive Summary ITEA Roadmap 2
Executive Summary ITEA Roadmap 2
 
01_Program
01_Program01_Program
01_Program
 

Recently uploaded

Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Julian Hyde
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
ICS
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
Remote DBA Services
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
Hornet Dynamics
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
Peter Muessig
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
Grant Fritchey
 
Requirement Traceability in Xen Functional Safety
Requirement Traceability in Xen Functional SafetyRequirement Traceability in Xen Functional Safety
Requirement Traceability in Xen Functional Safety
Ayan Halder
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Crescat
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
Sven Peters
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
ToXSL Technologies
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
Remote DBA Services
 
SMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API ServiceSMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API Service
Yara Milbes
 
UI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design SystemUI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design System
Peter Muessig
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
Philip Schwarz
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
Aftab Hussain
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
lorraineandreiamcidl
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
kalichargn70th171
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
Octavian Nadolu
 

Recently uploaded (20)

Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
 
Requirement Traceability in Xen Functional Safety
Requirement Traceability in Xen Functional SafetyRequirement Traceability in Xen Functional Safety
Requirement Traceability in Xen Functional Safety
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
 
SMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API ServiceSMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API Service
 
UI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design SystemUI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design System
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
 

Hash map

  • 3. Key VALUE pierre 01.42.78.96.12 paul 03.67.90.67.00 françois 01.45.87.90.45 mohamed 04.88.8945.29 khaled 06.98.56.22.48 laila 01.23.45.67.89 alex 34.56.15.27.78. claire 34.56.73.45.67 philippe 02.34.26.48.26. Hash() françois 01.45.87.90.45 Phone Numbers list example
  • 4. Key VALUE pierre 01.42.78.96.12 paul 03.67.90.67.00 françois 01.45.87.90.45 mohamed 04.88.8945.29 khaled 06.98.56.22.48 laila 01.23.45.67.89 alex 34.56.15.27.78. claire 34.56.73.45.67 philippe 02.34.26.48.26. Hash() françois 01.45.87.90.45 Phone Numbers list example Key Value
  • 5. Employees File SSN : Social Security Number 125675798988090 000000000000000 999999999999999 Social Security Number = address
  • 6. Employees File SSN : Social Security Number 125675798988090 000000000000000 999999999999999 Social Security Number = address steve mike john bob max edward John SSN : 125675798988090
  • 7. Employees File SSN : Social Security Number 125675798988090 000000000000000 999999999999999 Social Security Number = address steve mike john bob max edward Requires Memory size : 999999999999999 = 1E+15 = 1 petaoctet (Po) John SSN : 125675798988090
  • 8. Employees File SSN : Social Security Number 125675798988090 000000000000000 999999999999999 N element Array SSN 00 99 steve mike john bob max edward 125675798988090 100 employees
  • 9. Employees File SSN : Social Security Number 125675798988090 000000000000000 999999999999999 N element Array SSN 00 99 steve mike john bob max edward steve bob john mike edward125675798988090
  • 10. Employees File SSN : Social Security Number 125675798988090 000000000000000 999999999999999 N element Array SSN 00 99 steve mike john bob max edward steve bob john mike edward125675798988090
  • 11. Employees File SSN : Social Security Number 125675798988090 000000000000000 999999999999999 steve N element Array 00 99 KEY hash bob john mike edward value addresses steve mike john bob max edward
  • 16. Employees File SSN : Social Security Number 125675798988090 000000000000000 999999999999999 john N element Array 00 99 KEY hash bob mike edward value addresses steve mike john bob max edward Key space Address space
  • 17. Key space to Address space mapping 125675798988090 000000000000000 999999999999999 Address space Key space 00 99
  • 18. Key space to Address space mapping 125675798988090 000000000000000 999999999999999 Address space Key space Index 00 99
  • 20. Hash Function  The hash function is used to transform the key into the index (the hash) of an array element (the slot or bucket) where the corresponding value is to be stored and sought. KEY HASH index Value Bucket (slot)
  • 21. Hash table  hash table is an array-based data structure. 129007 926647 975378 269908 Fred Steve Richard Robert Key Value 0 1 3 4 5 2 index SSN
  • 22. Hash table  hash function is used to convert the key into the index of an array element, where associated value is to be seek. 129007 926647 975378 269908 Fred Steve Richard Robert Key Value h(129007) h(129007) h(975378) h(269908) 0 1 3 4 5 2 index SSN buckets
  • 23. Collision  If the hash function returns a slot that is already occupied there is a collision 129007 975378 269908 Fred Richard Robert Key Value H(129007) H(975378) H(269908) H(926647) 0 1 3 4 2
  • 24. 0 1 3 4 5 2 hash clustering  When the distribution of keys into buckets is not random, we say that the hash table exhibits clustering. 129007 975378 269908 Fred Richard Robert Key Value H(697803) H(975378) H(269908) H(926647) H(168477) H(129007) 6 7
  • 25. Hash function Good Hash function provides uniform distribution of hash values. Poor hash function will cause collisions and hash cluster.
  • 26. Hash Distribution Value # Hash 0 2 1 2 2 2 3 2 4 0 5 0 6 0 7 0 8 0 9 0 10 1 0 1 2 3 1 2 3 4 5 6 7 8 9 10 11 # Hash
  • 27. Hash Distribution 0 1 2 1 2 3 4 5 6 7 8 9 10 11 # Hash # Hash Value # Hash 0 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1
  • 28. Hash Distribution Value # Hash 0 0 1 0 2 0 3 1 4 3 5 5 6 3 7 1 8 0 9 0 10 0 0 1 2 3 4 5 6 1 2 3 4 5 6 7 8 9 10 11 # Hash # Hash
  • 29. Hash function toy implementation : Modulo N R CAR(R) mod (11) A 65 10 B 66 0 C 67 1 D 68 2 E 69 3 F 70 4 G 71 5 H 72 6 I 73 7 J 74 8 K 75 9 L 76 10 M 77 0 N 78 1 O 79 2 P 80 3 Q 81 4 R 82 5 S 83 6 T 84 7 U 85 8 V 86 9 W 87 10 X 88 0 Y 89 1 Z 90 2 26 => 11
  • 30. Modulo N Hash Distribution
  • 31. Load Factor Key Value 0 B 0 1 C 4 2 O 1 3 E 2 4 P 3 5 X 6 6 N 7 7 D 8 8 M 9 9 10 L 5 Key Value 0 B 0 1 C 4 2 O 1 3 E 2 4 P 3 5 X 6 6 N 7 7 D 8 8 M 9 9 10 L S 11 12 13 14 15 16 17 18 19 20 21 # elements in the hash Table size of the hash table 48 % 91 %
  • 32. Collision handling strategies Closed addressing (open hashing). Open addressing (closed hashing). 0 1 3 4 5 2 129007 975378 269908 Fred Richard Robert Key Value H(697803) H(975378) H(269908) H(926647) H(168477) H(129007) 6 7
  • 33. Open addressing (closed hashing).  When there is a collision, "Probe" the array to find an empty slot after the occupied slot. 129007 926647 975378 269908 Fred Steve Richard Robert Key Value H(697803) H(975378) H(269908) H(926647) 168477 Phil 697803 Greg H(168477) H(129007)
  • 34. Closed addressing (open hashing). Each slot of the hash table contains a link to another data structure. 129007 926647 975378 269908 Fred Steve 168477 Phil 697803 Greg Key 129007 975378 Richard 269908 Robert
  • 35. Linear Hashing • Linear Hashing – Re-hash : hi (x) = (h(x) + i) mod B • Stepsize : i • i = 1,2,3, … • Quadratic Hashing – Re-hash : hi (x) = (h (x) + i ²) mod B • Stepsize : i2 • i2 = 1,4,9,… • Double Hashing – Re-hash : hi (x) = (h(x) + i g (x)) mod B • Stepsize : g(x)
  • 36. Toy implementation example : R Attribut ARelation R RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M
  • 37. modulo Char Ascii Code Value Key RID R CAR(R) mod (11) 0 B 66 0 1 O 79 2 2 E 69 3 3 P 80 3 4 C 67 1 5 L 76 10 6 X 88 0 7 N 78 1 8 D 68 2 9 M 77 0
  • 38. Class HashLinearProbing  Hash(key)  returns hash  Put (key, value)  inserts key value pair  Get (key)  gets key value  Remove (key)  removes key preserving bucket structure.
  • 39. Class HashMap JSE 1.4 Object get(Object key) Returns the value to which the specified key is mapped in this identity hash map, or null if the map contains no mapping for this key. Object put(Object key, Object value) Associates the specified value with the specified key in this map. Object remove(Object key) Removes the mapping for this key from this map if present
  • 40. Linear Probing toy implementation RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M KEY VAL 0 1 2 3 4 5 6 7 8 9 10 M N Relation Data Structure Implementation Logical Physical
  • 41. Linear Probing toy implementation RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M KEY VAL 0 1 2 3 4 5 6 7 8 9 10 M N M > N Empty Slot is Search Stop Condition
  • 42. Linear Probing toy implementation RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M KEY VAL 0 1 2 3 4 5 6 7 8 9 10 11 10 M > N Empty Slot is Search Stop Condition
  • 43. Linear Probing KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 X 6 O 1 E 2 P 3 N 7 V 4 L 5 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0 Hash(key) First Empty Slot ? Put(N,7) %M Empty Slot is Search Place Stop Condition
  • 44. Linear Probing Hash(key) KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 X 6 O 1 E 2 P 3 N 7 K 8 M 9 V 4 L 5 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0 Car Y = 89 Y mod 11 = 1 Hash(key) Get(Y) Y ? Empty Stop Return (-1) Empty Slot is Search Stop Condition
  • 45. Linear Probing toy implementation RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M KEY VAL 0 1 2 3 4 5 6 7 8 9 10 11 10 M > N Empty Slot is Search Stop Condition At least one empty slot M – N = 1
  • 46. Linear Probing RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M KEY VAL 0 1 2 3 4 5 6 7 8 9 10 M N
  • 47. Linear Probing KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M Example Relation Implementation
  • 48. Linear Probing KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 Hash(key) = CAR(R) Mod (M) M = 11 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0
  • 49. Linear Probing KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 Hash(key) Put(B,0) Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0
  • 50. Linear Probing KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 O 1 Hash(key) Put(O,1) Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0
  • 51. Linear Probing KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 O 1 E 2 Hash(key) Put(E,2) Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0
  • 52. Linear Probing KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 O 1 E 2 P 3 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0 Hash(key) First Empty Slot ? Put(P,3)
  • 53. Linear Probing KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 O 1 E 2 P 3 V 4 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0 Hash(key) Put(V,4)
  • 54. Linear Probing KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 O 1 E 2 P 3 V 4 L 5 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0 Hash(key) Put(L,5)
  • 55. Linear Probing KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 X 6 O 1 E 2 P 3 V 4 L 5 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0 Hash(key) First Empty Slot ? Put(X,6) %M
  • 56. Linear Probing KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 X 6 O 1 E 2 P 3 N 7 V 4 L 5 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0 Hash(key) First Empty Slot ? Put(N,7) %M
  • 57. Linear Probing Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0 Hash(key) First Empty Slot ? Put(K,8) %M KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 X 6 O 1 E 2 P 3 N 7 K 8 V 4 L 5
  • 58. Linear Probing Hash(key) Put(M,9) KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 X 6 O 1 E 2 P 3 N 7 K 8 M 9 V 4 L 5 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M First Empty Slot ? 0 2 3 3 9 10 0 1 9 0
  • 59. Linear Probing Hash(key) Put(M,9) KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 X 6 O 1 E 2 P 3 N 7 K 8 M 9 V 4 L 5 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0
  • 60. Linear Probing Hash(key) Put(M,9) KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 X 6 O 1 E 2 P 3 N 7 K 8 M 9 V 4 L 5 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0
  • 61. Implementation of function Hash(Key)  In Java : Key % M  Specific case of Java char : in Java char are integer (Byte).  char: The char data type is a single 16-bit Unicode character. It has a minimum value of 'u0000' (or 0) and a maximum value of 'uffff' (or 65,535 inclusive).  Null char is 0 (zero).  Default value for char is 0, or u0000. Hash (Key) { Return Key Modulo M } http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html
  • 62. Bucket Table Implementation KEY VAL char keys Array [M] int values Array [M]
  • 63. Put(key, value) simplified algo M = # bucket entries index = hash (key) While Key [index) != empty index = (index + 1) % M End while Key [index] = key Values [index] = value
  • 64. Get(Key)  Get existing key  Get non inserted key
  • 65. Linear Probing Hash(key) KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 X 6 O 1 E 2 P 3 N 7 K 8 M 9 V 4 L 5 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0 Hash(key)Hash(key) Get(B) B,0 B ?
  • 66. Linear Probing Hash(key) KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 X 6 O 1 E 2 P 3 N 7 K 8 M 9 V 4 L 5 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0 Hash(key) Get(M) M ? M, 9
  • 67. Linear Probing Hash(key) KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 X 6 O 1 E 2 P 3 N 7 K 8 M 9 V 4 L 5 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0 Hash(key) K ? K,8 Get(K)
  • 68. Linear Probing Hash(key) KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 X 6 O 1 E 2 P 3 N 7 K 8 M 9 V 4 L 5 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0 Car Y = 89 Y mod 11 = 1 Hash(key) Get(Y) Y ? Empty Stop Return (-1)
  • 69. Get(key) M = # buckets index = hash (key) valueToReturn = -1 // value to return if the key is not in the map While Key [index] != key and Key [index] != empty index = (index + 1) % M End while If (Key [index] = key) valueToReturn = Values [index] Return valueToReturn
  • 70. Remove (Key)  Remove (M)  Remove (N) : rehash end of the cluster.  Remove (L) : rehash end of the cluster.
  • 71. Linear Probing Hash(key) KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 X 6 O 1 E 2 P 3 N 7 K 8 M 9 V 4 L 5 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0 Hash(key) Remove (M) K(0) != M Blank Scan for M
  • 72. Linear Probing Hash(key) KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 X 6 O 1 E 2 P 3 N 7 K 8 V 4 L 5 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0 Hash(key) Remove (M) K(0) != M Blank Scan for M
  • 73. Linear Probing Hash(key) KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 X 6 O 1 E 2 P 3 N 7 K 8 M 9 V 4 L 5 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0 Hash(key) Remove (N) K(1) != N Blank and rehash End of cluster Scan for N
  • 74. Linear Probing Hash(key) KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 X 6 O 1 E 2 P 3 N 7 K 8 M 9 V 4 L 5 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0 Cluster Remove (N) K(1) != N Blank and rehash End of cluster Scan for N
  • 75. Linear Probing Hash(key) KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 X 6 O 1 E 2 P 3 K 8 M 9 V 4 L 5 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0 Remove (N) K(1) != N Blank and rehash End of cluster Scan for N EOf cluster
  • 76. Linear Probing Hash(key) KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 X 6 O 1 E 2 P 3 K 8 M 9 V 4 L 5 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0 Remove (N) K(1) != N Blank and rehash End of cluster Scan for N EOf cluster Blank Key(6) , Val(6) put(K,8)
  • 77. Linear Probing Hash(key) KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 X 6 O 1 E 2 P 3 M 9 V 4 L 5 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0 Remove (N) K(1) != N Blank and rehash End of cluster Scan for N EOf cluster Blank Key(6) , Val(6) put(K,8)
  • 78. Linear Probing Hash(key) KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 X 6 O 1 E 2 P 3 M 9 V 4 L 5 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0 Remove (N) K(1) != N Blank and rehash End of cluster Scan for N Blank Key(6) , Val(6) put(K,8)
  • 79. Linear Probing Hash(key) KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 X 6 O 1 E 2 P 3 M 9 V 4 L 5 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0 Remove (N) K(1) != N Blank and rehash End of cluster Scan for N Blank Key(6), Val(6) put(K,8)
  • 80. Linear Probing Hash(key) KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 X 6 O 1 E 2 P 3 K 8 M 9 V 4 L 5 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0 Remove (N) K(1) != N Blank and rehash End of cluster Scan for N Blank Key(7) ,Val(7) put(K,8)
  • 81. Linear Probing Hash(key) KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 X 6 O 1 E 2 P 3 K 8 M 9 V 4 L 5 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0 Remove (N) K(1) != N Blank and rehash End of cluster Scan for N Blank Key(7) ,Val(7) put(K,8)
  • 82. Linear Probing Hash(key) KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 X 6 O 1 E 2 P 3 K 8 V 4 L 5 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0 Remove (N) K(1) != N Blank and rehash End of cluster Scan for N Blank Key(7) , Val(7) put(M,9)
  • 83. Linear Probing Hash(key) KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 X 6 O 1 E 2 P 3 K 8 V 4 L 5 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0 Remove (N) K(1) != N Blank and rehash End of cluster Scan for N Blank Key(7) , Val(7) put(M,9) First Empty Slot ?
  • 84. Linear Probing Hash(key) KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 X 6 O 1 E 2 P 3 K 8 9 V 4 L 5 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0 Remove (N) K(1) != N Blank and rehash End of cluster Scan for N Blank Key(7) , Val(7) put(M,9) First Empty Slot ? M
  • 85. Linear Probing Hash(key) KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 X 6 O 1 E 2 P 3 N 7 K 8 M 9 V 4 L 5 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0 Remove (L)
  • 86. Linear Probing Hash(key) KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 X 6 O 1 E 2 P 3 N 7 K 8 M 9 V 4 L 5 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0 K(10) = L blank Remove (L) Blank and rehash End of cluster
  • 87. Linear Probing Hash(key) KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 X 6 O 1 E 2 P 3 N 7 K 8 M 9 V 4 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0 K(10) = L blank Remove (L) Blank and rehash End of cluster
  • 88. Linear Probing Hash(key) KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 X 6 O 1 E 2 P 3 N 7 K 8 M 9 V 4 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0 K(10) = L blank Remove (L) Blank and rehash End of cluster EOf cluster
  • 89. Linear Probing Hash(key) KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 X 6 O 1 E 2 P 3 N 7 K 8 M 9 V 4 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0 Remove (L) Blank and rehash End of cluster EOf cluster Blank Key(0) , Val(0) put(B,0)
  • 90. Linear Probing Hash(key) KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 X 6 O 1 E 2 P 3 N 7 K 8 M 9 V 4 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0 Remove (L) Blank and rehash End of cluster EOf cluster Blank Key(1) , Val(1) put(X,6)
  • 91. Linear Probing Hash(key) KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 X 6 O 1 E 2 P 3 N 7 K 8 M 9 V 4 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0 Remove (L) Blank and rehash End of cluster EOf cluster Blank Key(2) , Val(2) put(O,1)
  • 92. Linear Probing Hash(key) KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 X 6 O 1 E 2 P 3 N 7 K 8 M 9 V 4 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0 Remove (L) Blank and rehash End of cluster EOf cluster Blank Key(3) , Val(3) put(E,2)
  • 93. Linear Probing Hash(key) KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 X 6 O 1 E 2 P 3 N 7 K 8 M 9 V 4 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0 Remove (L) Blank and rehash End of cluster EOf cluster Blank Key(4), Val(4) put(P,3)
  • 94. Linear Probing Hash(key) KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 X 6 O 1 E 2 P 3 N 7 K 8 M 9 V 4 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0 Remove (L) Blank and rehash End of cluster EOf cluster Blank Key(5), Val(5) put(N,7)
  • 95. Linear Probing Hash(key) KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 X 6 O 1 E 2 P 3 N 7 K 8 M 9 V 4 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0 Remove (L) Blank and rehash End of cluster EOf cluster Blank Key(6) , Val(6) put(K,8)
  • 96. Linear Probing Hash(key) KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 X 6 O 1 E 2 P 3 N 7 M 9 V 4 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0 Remove (L) Blank and rehash End of cluster EOf cluster Blank Key(6) , Val(6) put(K,8)
  • 97. Linear Probing Hash(key) KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 X 6 O 1 E 2 P 3 N 7 M 9 V 4 K 8 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0 Remove (L) Blank and rehash End of cluster EOf cluster Blank Key(6) , Val(6) put(K,8)
  • 98. Linear Probing Hash(key) KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 X 6 O 1 E 2 P 3 N 7 M 9 V 4 K 8 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0 Remove (L) Blank and rehash End of cluster EOf cluster Blank Key(7) , Val(7) put(M,9)
  • 99. Linear Probing Hash(key) KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 X 6 O 1 E 2 P 3 N 7 M 9 V 4 K 8 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0 Remove (L) Blank and rehash End of cluster EOf cluster Blank Key(7) , Val(7) put(M,9)
  • 100. Linear Probing Hash(key) KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 X 6 O 1 E 2 P 3 N 7 M 9 V 4 K 8 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0 Remove (L) Blank and rehash End of cluster EOf cluster Blank Key(7) , Val(7) put(M,9)
  • 101. Linear Probing Hash(key) KEY VAL B 00 1 2 3 4 5 6 7 8 9 10 X 6 O 1 E 2 P 3 N 7 M 9 V 4 K 8 Value Key RID R 0 B 1 O 2 E 3 P 4 V 5 L 6 X 7 N 8 K 9 M 0 2 3 3 9 10 0 1 9 0 Remove (L) Blank and rehash End of cluster EOf cluster Blank Key(7) , Val(7) put(M,9)
  • 102. Remove (key) simplified algo M = # buckets index = hash (key) While Key [index) != key and Key [index) != empty index = (index + 1) % M End while Key [index] = 0, Value [index] = 0 // rehash index = (index + 1) % M While Key [index) != empty savedKey = Key [index], savedValue = Value [index] Key [index] = 0 Value [index] = 0 Put ( savedKey , savedValue ) index = (index + 1) % M End while