Hashing
Separate chaning
by
Vijayapriya p
I Mcs(cs)
hashing
Hashing is process of mapping
large amount of data item to smaller
table
with the help of hashing function.
Hashing is also known as hashing
algorithm or message digest function.
It is a technique to convert a range of
Key values into a range of indexes of an
array.
Hashing is a array.
That calculates a fixed-size bit string
Value from a file.
Types of hashing
hashing
Static
hashing
Dynamic
hashing
Static hashing
In the static hashing, the resultant data
bucket addresss will always remain
The same.
In the dynamic hashing offers a
Mechanism in which data buckets are
Added and removed dynamically
And on demand.
Dynamic hashing
Dynamic hashing ,only a small amount of data is
ever accessed at one time.
 it easier on a computer’s resources to
Perform one or more of the following
commands.
Insert
Delete
Update
query
collision
When two values hash to the same
array location, this is called a collision.
“first come, first saved”
Collision resolution techniques
Separate chaning
(open hashing)
Open addressing
(closed hashing)
•Linear probing
•Ouadratic probing
•Double hashing
Using array method
Using linked list method
Binary search tree method(BST)
15 7 11 5 13
Binary tree is called an ordered or sorted
binary tree.
Is a rooted binary tree
Input values
Create Hash table
hash fun=input%hash table size
Input value:
15 7 11 5 13
o Hash fun= 15%7 =1
o Hash fun= 7%7 =0
o Hash fun= 11%7 =4
o Hash fun = 5%7 =2
o Hash fun= 13%7 =6
Number of iteration=1
Time complexity=0(1)
Separate chaning
A scheme in which each position in the
Hash table a list to handle collision.
Each position may be just a link to the list
(direct chaning) or may be an item and a
Link essentially, the head of a list
This tecnique creates a linked list to the
slot for which collision occurs.
The new key is then inserted in the linked
List.
Linked lists to the slots appear like chains.
This tecnique is called as separate chaning
Hash table
Hash(50)=50%7=1
Example
Input value:
50 700 76 85 92 73 101
Has fun(data) =data % tablesize
Has fun(50) =50%7 =1
Has fun(700) =700%7 =o
Has fun(76) =76%7 =6
Has fun(85) =85%7 =1
Has fun (92) =92%7 =1
Has fun(73)=73%7=3
Has fun(101)=101%7=3
Hashing and separate chain

Hashing and separate chain