Professional Documents
Culture Documents
This Photo CC By-Sa-Nc: by Unknown Author Is Licensed Under
This Photo CC By-Sa-Nc: by Unknown Author Is Licensed Under
HASH TABLE
SABA ZAIRA 3908-FBAS/BSCS/F18
FATIMA RAUF 3907-FBAS/BSCS/F18
MUBARRA KHALID 3906-FBAS/BSCS/F18
ANEETA TABASUM 3893-FBAS/BSCS/F18
HASH TABLE
• Data Structure
• Key-Value pair
unique keys
Keys are address
Each value is associated with mapped key
STRUCTURE
6
76
FOR LARGE NUMBERS(FOLDING METHOD):
Break it into groups of 2 digits and add them then divide it to the size of hash
table and reminder will be the index.
NUM:
0145283450
01+45+28+34+50=203
203%size of hash table=address for num
COLLISION
When two keys have the same hash value
• example:
“9" and “620“ for size “13”
9%13=9
620%13=9
Here both the values collided.
IMPROVEMENTS:
• Linear probing
• Chaining
• Resizing the hash table
Linear
Probing
EXAMPLE
CHAINING
EXAMPLE
WORKING
INSERT
DELETE
FIND
COMPLAXIT
IES
Algorithm Best Average Worst case
Space O(n) O(n) O(n)
Search O(1) O(1) O(n)
Insert O(1) O(1) O(n)
Delete O(1) O(1) O(n)
Worst Case
If the keys we encounter,
all keys may hash to the
same bucket.