SlideShare a Scribd company logo
1 of 17
Download to read offline
HASHING
-Satish Kumar Inumarthi
AGENDA
• Why hashing?
• What is hashing?
• Hashing functions
• Collision resolution techniques
WHY HASHING?
We are going to Direct Address Table to reduce the search time
In DMA there is wastage of storage
In order to organize the storage we are moving for Hashing
• HASHING:
• HASH TABLE: It is a simple data structure ,which stores the keys in table in it’s
corresponding position
• HASH FUNCTION: It is a mathematical formula inorder to get the index to
store keys
DIFFERENT HASHING FUNCTIONS
• 1.Division method
• 2.Multiplicative method
• 3.Mid square method
• 4.Folded method
DIVISION METHOD
• Let the keys are k1,k2,k3…….kn
• Formula: Ki%m,
• where m is the size of the hash table
• n =1,2,3,4…….n
MULTIPLICATIVE METHOD
• Choose value between 0 &1
• Let the value be ‘A’
• R<-(A*k)mod (l)
• where l is
• k is the key
• Take the fractional part
• Apply hash function on result
• H(R)<-R%m
• where m is size of hash table
•
MID SQUARE METHOD
• Take middle key depending on the hashtable size
• K=k^2
• Apply normal hash function(division method)
FOLDED METHOD
• Divide the values into parts
• Add the digits
• Apply normal hash function(division method)
• Ex :123450
• 12 | 34 |50
• 375
COLLISION RESOLUTION TECHNIQUES
• While applying hash functions ,collisions will occur. In order to manage
collisions we are going to follow below techniques
CHAINING
• Hash table contains the pointers pointing to the linked lists
Disadvantage: In worst case we require O(n) to search an element
We are using pointers ,which require much memory
In order to overcome this we are moving for open addressing
OPEN ADDRESSING
• When collision occurs ,we go for probe new sequence
• We search for next free location
• Overflow: It occurs when hash table was filled (we couldn’t find any free
location)
LINEAR PROBING
Linear Probing resolves collisions by placing the data
into the next open slot in the table
h(k,i)=(h’(k)+i)%m
h’(k)=h(k)%m
QUADRATIC PROBING
• Quadratic probing is an open addressing scheme for resolving collisions in
hash tables—when an incoming data's hash value indicates it should be
stored in an already-occupied slot or bucket
• Formula:(h’(k)+C1(i)+C2 (i^2))%m
DOUBLE HASHING
• Double hashing is one of the best methods for dealing with collisions.
• If the slot is full, then a second hash function is calculated and combined with
the first hash function.
• H(k, i) = (H1(k) + i H2(k) ) % m
REHASHING
• Rehashing: Means hashing again. ... So to overcome this, the size of the array
is doubled and all the values are hashed again and stored in the new
double sized array to maintain a low load factor and low complexity.
THE END

More Related Content

What's hot

Hashing and Hash Tables
Hashing and Hash TablesHashing and Hash Tables
Hashing and Hash Tablesadil raja
 
Hashing In Data Structure
Hashing In Data Structure Hashing In Data Structure
Hashing In Data Structure Meghaj Mallick
 
Priority Queue in Data Structure
Priority Queue in Data StructurePriority Queue in Data Structure
Priority Queue in Data StructureMeghaj Mallick
 
Parsing in Compiler Design
Parsing in Compiler DesignParsing in Compiler Design
Parsing in Compiler DesignAkhil Kaushik
 
Dinive conquer algorithm
Dinive conquer algorithmDinive conquer algorithm
Dinive conquer algorithmMohd Arif
 
Hashing And Hashing Tables
Hashing And Hashing TablesHashing And Hashing Tables
Hashing And Hashing TablesChinmaya M. N
 
Priority queue in DSA
Priority queue in DSAPriority queue in DSA
Priority queue in DSAjunnubabu
 
Trees in data structure
Trees in data structureTrees in data structure
Trees in data structureAnusruti Mitra
 
Hashing and Hashtable, application of hashing, advantages of hashing, disadva...
Hashing and Hashtable, application of hashing, advantages of hashing, disadva...Hashing and Hashtable, application of hashing, advantages of hashing, disadva...
Hashing and Hashtable, application of hashing, advantages of hashing, disadva...NaveenPeter8
 

What's hot (20)

B trees dbms
B trees dbmsB trees dbms
B trees dbms
 
Hashing and Hash Tables
Hashing and Hash TablesHashing and Hash Tables
Hashing and Hash Tables
 
linear probing
linear probinglinear probing
linear probing
 
Hashing In Data Structure
Hashing In Data Structure Hashing In Data Structure
Hashing In Data Structure
 
Hashing
HashingHashing
Hashing
 
4.4 hashing
4.4 hashing4.4 hashing
4.4 hashing
 
Quadratic probing
Quadratic probingQuadratic probing
Quadratic probing
 
DBMS 9 | Extendible Hashing
DBMS 9 | Extendible HashingDBMS 9 | Extendible Hashing
DBMS 9 | Extendible Hashing
 
Priority Queue in Data Structure
Priority Queue in Data StructurePriority Queue in Data Structure
Priority Queue in Data Structure
 
Binary search tree(bst)
Binary search tree(bst)Binary search tree(bst)
Binary search tree(bst)
 
Parsing in Compiler Design
Parsing in Compiler DesignParsing in Compiler Design
Parsing in Compiler Design
 
Dinive conquer algorithm
Dinive conquer algorithmDinive conquer algorithm
Dinive conquer algorithm
 
Hashing And Hashing Tables
Hashing And Hashing TablesHashing And Hashing Tables
Hashing And Hashing Tables
 
Chapter 12 ds
Chapter 12 dsChapter 12 ds
Chapter 12 ds
 
Priority queue in DSA
Priority queue in DSAPriority queue in DSA
Priority queue in DSA
 
Hash table
Hash tableHash table
Hash table
 
Sorting
SortingSorting
Sorting
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting Algorithms
 
Trees in data structure
Trees in data structureTrees in data structure
Trees in data structure
 
Hashing and Hashtable, application of hashing, advantages of hashing, disadva...
Hashing and Hashtable, application of hashing, advantages of hashing, disadva...Hashing and Hashtable, application of hashing, advantages of hashing, disadva...
Hashing and Hashtable, application of hashing, advantages of hashing, disadva...
 

Similar to Hashing

PPT 2 wirha DSA hasings dvd ho gi of DJ of ch huu Raj of DJ.pptx
PPT 2 wirha DSA hasings dvd ho gi of DJ of ch huu Raj of DJ.pptxPPT 2 wirha DSA hasings dvd ho gi of DJ of ch huu Raj of DJ.pptx
PPT 2 wirha DSA hasings dvd ho gi of DJ of ch huu Raj of DJ.pptxCHANDUS31
 
Lecture14_15_Hashing.pptx
Lecture14_15_Hashing.pptxLecture14_15_Hashing.pptx
Lecture14_15_Hashing.pptxSLekshmiNair
 
Hashing techniques, Hashing function,Collision detection techniques
Hashing techniques, Hashing function,Collision detection techniquesHashing techniques, Hashing function,Collision detection techniques
Hashing techniques, Hashing function,Collision detection techniquesssuserec8a711
 
Hash in datastructures by using the c language.pptx
Hash in datastructures by using the c language.pptxHash in datastructures by using the c language.pptx
Hash in datastructures by using the c language.pptxmy6305874
 
HASHING IS NOT YASH IT IS HASH.pptx
HASHING IS NOT YASH IT IS HASH.pptxHASHING IS NOT YASH IT IS HASH.pptx
HASHING IS NOT YASH IT IS HASH.pptxJITTAYASHWANTHREDDY
 
Hashing using a different methods of technic
Hashing using a different methods of technicHashing using a different methods of technic
Hashing using a different methods of techniclokaprasaadvs
 
Analysis Of Algorithms - Hashing
Analysis Of Algorithms - HashingAnalysis Of Algorithms - Hashing
Analysis Of Algorithms - HashingSam Light
 
Hashing.pptx
Hashing.pptxHashing.pptx
Hashing.pptxkratika64
 
Data Structure and Algorithms Hashing
Data Structure and Algorithms HashingData Structure and Algorithms Hashing
Data Structure and Algorithms HashingManishPrajapati78
 
Hashing In Data Structure Download PPT i
Hashing In Data Structure Download PPT iHashing In Data Structure Download PPT i
Hashing In Data Structure Download PPT icajiwol341
 
Concept of hashing
Concept of hashingConcept of hashing
Concept of hashingRafi Dar
 

Similar to Hashing (20)

LECT 10, 11-DSALGO(Hashing).pdf
LECT 10, 11-DSALGO(Hashing).pdfLECT 10, 11-DSALGO(Hashing).pdf
LECT 10, 11-DSALGO(Hashing).pdf
 
PPT 2 wirha DSA hasings dvd ho gi of DJ of ch huu Raj of DJ.pptx
PPT 2 wirha DSA hasings dvd ho gi of DJ of ch huu Raj of DJ.pptxPPT 2 wirha DSA hasings dvd ho gi of DJ of ch huu Raj of DJ.pptx
PPT 2 wirha DSA hasings dvd ho gi of DJ of ch huu Raj of DJ.pptx
 
Lecture14_15_Hashing.pptx
Lecture14_15_Hashing.pptxLecture14_15_Hashing.pptx
Lecture14_15_Hashing.pptx
 
Hashing techniques, Hashing function,Collision detection techniques
Hashing techniques, Hashing function,Collision detection techniquesHashing techniques, Hashing function,Collision detection techniques
Hashing techniques, Hashing function,Collision detection techniques
 
Hash in datastructures by using the c language.pptx
Hash in datastructures by using the c language.pptxHash in datastructures by using the c language.pptx
Hash in datastructures by using the c language.pptx
 
Hash tables
Hash tablesHash tables
Hash tables
 
8. Hash table
8. Hash table8. Hash table
8. Hash table
 
HASHING IS NOT YASH IT IS HASH.pptx
HASHING IS NOT YASH IT IS HASH.pptxHASHING IS NOT YASH IT IS HASH.pptx
HASHING IS NOT YASH IT IS HASH.pptx
 
Hashing .pptx
Hashing .pptxHashing .pptx
Hashing .pptx
 
Hashing using a different methods of technic
Hashing using a different methods of technicHashing using a different methods of technic
Hashing using a different methods of technic
 
L21_Hashing.pdf
L21_Hashing.pdfL21_Hashing.pdf
L21_Hashing.pdf
 
Hashing
HashingHashing
Hashing
 
Analysis Of Algorithms - Hashing
Analysis Of Algorithms - HashingAnalysis Of Algorithms - Hashing
Analysis Of Algorithms - Hashing
 
Unit viii searching and hashing
Unit   viii searching and hashing Unit   viii searching and hashing
Unit viii searching and hashing
 
Hashing.pptx
Hashing.pptxHashing.pptx
Hashing.pptx
 
Hashing
HashingHashing
Hashing
 
Data Structure and Algorithms Hashing
Data Structure and Algorithms HashingData Structure and Algorithms Hashing
Data Structure and Algorithms Hashing
 
Hashing In Data Structure Download PPT i
Hashing In Data Structure Download PPT iHashing In Data Structure Download PPT i
Hashing In Data Structure Download PPT i
 
Concept of hashing
Concept of hashingConcept of hashing
Concept of hashing
 
Hashing_UNIT2.pptx
Hashing_UNIT2.pptxHashing_UNIT2.pptx
Hashing_UNIT2.pptx
 

Recently uploaded

Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 

Recently uploaded (20)

Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 

Hashing

  • 2. AGENDA • Why hashing? • What is hashing? • Hashing functions • Collision resolution techniques
  • 3. WHY HASHING? We are going to Direct Address Table to reduce the search time In DMA there is wastage of storage In order to organize the storage we are moving for Hashing
  • 4. • HASHING: • HASH TABLE: It is a simple data structure ,which stores the keys in table in it’s corresponding position • HASH FUNCTION: It is a mathematical formula inorder to get the index to store keys
  • 5. DIFFERENT HASHING FUNCTIONS • 1.Division method • 2.Multiplicative method • 3.Mid square method • 4.Folded method
  • 6. DIVISION METHOD • Let the keys are k1,k2,k3…….kn • Formula: Ki%m, • where m is the size of the hash table • n =1,2,3,4…….n
  • 7. MULTIPLICATIVE METHOD • Choose value between 0 &1 • Let the value be ‘A’ • R<-(A*k)mod (l) • where l is • k is the key • Take the fractional part • Apply hash function on result • H(R)<-R%m • where m is size of hash table •
  • 8. MID SQUARE METHOD • Take middle key depending on the hashtable size • K=k^2 • Apply normal hash function(division method)
  • 9. FOLDED METHOD • Divide the values into parts • Add the digits • Apply normal hash function(division method) • Ex :123450 • 12 | 34 |50 • 375
  • 10. COLLISION RESOLUTION TECHNIQUES • While applying hash functions ,collisions will occur. In order to manage collisions we are going to follow below techniques
  • 11. CHAINING • Hash table contains the pointers pointing to the linked lists Disadvantage: In worst case we require O(n) to search an element We are using pointers ,which require much memory In order to overcome this we are moving for open addressing
  • 12. OPEN ADDRESSING • When collision occurs ,we go for probe new sequence • We search for next free location • Overflow: It occurs when hash table was filled (we couldn’t find any free location)
  • 13. LINEAR PROBING Linear Probing resolves collisions by placing the data into the next open slot in the table h(k,i)=(h’(k)+i)%m h’(k)=h(k)%m
  • 14. QUADRATIC PROBING • Quadratic probing is an open addressing scheme for resolving collisions in hash tables—when an incoming data's hash value indicates it should be stored in an already-occupied slot or bucket • Formula:(h’(k)+C1(i)+C2 (i^2))%m
  • 15. DOUBLE HASHING • Double hashing is one of the best methods for dealing with collisions. • If the slot is full, then a second hash function is calculated and combined with the first hash function. • H(k, i) = (H1(k) + i H2(k) ) % m
  • 16. REHASHING • Rehashing: Means hashing again. ... So to overcome this, the size of the array is doubled and all the values are hashed again and stored in the new double sized array to maintain a low load factor and low complexity.