Closed Hashing-ADS
Closed Hashing-ADS
Prof. B.B.Kotame
Assistant Professor
E-mail : [email protected]
Contact No:9561010331
• Open Addressing/Closed Hashing:
3. As all the elements are stored inside the table, a large memory space is
needed for open addressing.
• Linear Probing
• Quadratic Probing
• Double Hashing
• If collision occurs, the identifier is place in the next empty slot after its home
bucket
• Insert keys:20,30,2,13,25,24,10,9 0 0 0 0 0 0 9
1 1 1 1 1 1
2 2 2 2 2 2 2 2 2 2 2 2
h(20)= 20 % 11=9 3 3 13 3 13 3 13 3 13 3 13
h(30)= 30 % 11=8 4 4 4 25 4 25 4 25 4 25
h(2)= 2 % 11 =2 5 5 5 5 24 5 24 5 24
h(13)= 13 % 11=2 6 6 6 6 6 6
h(25)= 25 % 11=3 7 7 7 7 7 7
h(24)= 24 % 11=2 8 30 8 30 8 30 8 30 8 30 8 30
h(10)= 10 % 11=10 9 20 9 20 9 20 9 20 9 20 9 20
h(9)= 9 % 11=9 10 10 10 10 10 10 10 10
1. Simple to implement.
• Disadvantages :
• In this field, the address of the colliding data can be stored with the first colliding
element in the chain table, without replacement.
h(3)= 3%10=3 2 -1 -1 2 21 5 2 21 5 2 21 5 2 21 5
h(4)= 4%10=4 3 3 -1 3 3 -1 3 3 -1 3 3 -1 3 3 -1
h(21)= 21%10=1 4 4 -1 4 4 -1 4 4 -1 4 4 -1 4 4 -1
h(61)= 61%10=1 5 -1 -1 5 61 -1 5 61 -1 5 61 7 5 61 7
h(6)= 6%10=6 6 -1 -1 6 -1 -1 6 6 -1 6 6 -1 6 6 -1
h(71)= 71%10=1 7 -1 -1 7 -1 -1 7 -1 -1 7 71 -1 7 71 -1
h(8)= 8%10=8 8 -1 -1 8 -1 -1 8 -1 -1 8 -1 -1 8 8 -1
h(9)= 9%10=9 9 -1 -1 9 -1 -1 9 -1 -1 9 -1 -1 9 9 -1
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
1. Main purpose of hashing is not achieved, because all records are not
mapped at correct position or mapped at wrong position/address.
• e.g. 11,32,41,54,33
• First 3 will get placed at address 1,2,3,4. but when 33 need to be placed it
position is occupied by 41.
• Therefore 33 replaces 41 and 41 inserted in new empty bucket i.e. 5 and chain
from element 11 at position 1 is modified