SlideShare a Scribd company logo
Hashing Algorithms and its
applications
Introduction to data sorting and Key searching
What is Hash table?
• A faster way to access data keeping table
• Also known as bucket
• It can be an array of objects (that has all the data)
• Requires a function to convert the real data into placing position
deciding data
• Can use part of the data or time/space stamp to decide the position
• The position is termed as HASH
Randomness of Data
• Data can be of defined pattern and length for which we can have
static length of hash table entries
• Each hash table entry place is a position that is access by the key
• The key is calculated by hash function
• If we know the data pattern, we can easily solve all the key
calculations and also know the number of rows in the has table
• If the data is random, we don’t know the number of entries in the
table
Hashing Function
• Calculates the key for address assignment
• Key = position Hasher (Type entry)
• position StoringPosition = HashTable[Key]
• Here the Hasher is “to add the ASCII values of
Each letter and then take modulo 11”
• Folding:
• A method that divides data into chunks for processing in a Hasher
Normal allocation
• The data is processed using has function
• The hash that is created by the function is searched in the table
• The data is placed there
Collision
• The Hasher gives a key that is already occupied
• Normally, the old value is discarded and the new incoming data is
stored
• It is probable when the table space is lesser than the incoming data
• Even if table data space is greater than the incoming data, this
problem is probable to occur
Solution to Collision
• Open Addressing
• Same level address is used but on a different location which is calculated by
the user defined rule
• Linear Probing (the entry is saved in the next free space) - It can create clustering
• Plus 3 rehash (the key is are-calculated by adding 3 to the previous entry value)
• Quadratic Probing (the entry is saved by leaving 1, 2, 4, 16 spaces on the HT)
• Double Hashing (Finding the hash of the key obtained)
• PreviousHashKey = Hasher(entry)
• NewHash = Hasher(PreviousHashKey)
• Closed Addressing
• Creating chains
Data Searching and Retrieval
• The data that we want to search uses the same Hash Function
• After the Hasher calculates the Key, it is given directly to the table
Variable and that position has the data
• Search is usually O(n) for linear search and O(log(n)) for binary search
but this method makes the search operation reduced to O(1)
• O(1) means that we calculated the key in a fixed time process and the
we go to the Array[key] to retrieve data using fixed time again
• In case of chaining, we traverse on the node to reach our data so that
makes it an O(n), still faster than complete search strategy.
Linear Probing
Chaining using Linked List
A good Hash Function!
• Minimum Collisions
• Uniform distribution of hash values/keys (avoid clustering)
• Easy to calculate Hash
• Resolve the collision swiftly
Summary
• Used to index large data sets
• Address of each key is calculated by the data itself
• Collision resolved with open or closed addressing
• Hashing is widely used in database indexing, compilers, caching,
password authentication, Blockchain, etc.
• Insert, Delete and retrieve occurs on a fixed time (mostly)

More Related Content

What's hot

Lec 17 heap data structure
Lec 17 heap data structureLec 17 heap data structure
Lec 17 heap data structure
Sajid Marwat
 

What's hot (20)

Hash function
Hash function Hash function
Hash function
 
Traditional symmetric-key cipher
Traditional symmetric-key cipherTraditional symmetric-key cipher
Traditional symmetric-key cipher
 
Hash tables
Hash tablesHash tables
Hash tables
 
Data Structures : hashing (1)
Data Structures : hashing (1)Data Structures : hashing (1)
Data Structures : hashing (1)
 
Hashing PPT
Hashing PPTHashing PPT
Hashing PPT
 
Lec 17 heap data structure
Lec 17 heap data structureLec 17 heap data structure
Lec 17 heap data structure
 
Data Encryption Standard (DES)
Data Encryption Standard (DES)Data Encryption Standard (DES)
Data Encryption Standard (DES)
 
18 hashing
18 hashing18 hashing
18 hashing
 
Operator Precedence Grammar
Operator Precedence GrammarOperator Precedence Grammar
Operator Precedence Grammar
 
Chapter 12 ds
Chapter 12 dsChapter 12 ds
Chapter 12 ds
 
Block Ciphers and the Data Encryption Standard
Block Ciphers and the Data Encryption StandardBlock Ciphers and the Data Encryption Standard
Block Ciphers and the Data Encryption Standard
 
Hash table
Hash tableHash table
Hash table
 
Cryptography
CryptographyCryptography
Cryptography
 
Hashing In Data Structure
Hashing In Data Structure Hashing In Data Structure
Hashing In Data Structure
 
Hashing data
Hashing dataHashing data
Hashing data
 
Hashing
HashingHashing
Hashing
 
Hashing .pptx
Hashing .pptxHashing .pptx
Hashing .pptx
 
AES KEY EXPANSION .pptx
AES KEY EXPANSION .pptxAES KEY EXPANSION .pptx
AES KEY EXPANSION .pptx
 
Data Structure and Algorithms Binary Search Tree
Data Structure and Algorithms Binary Search TreeData Structure and Algorithms Binary Search Tree
Data Structure and Algorithms Binary Search Tree
 
Hash table
Hash tableHash table
Hash table
 

Similar to Hashing algorithms and its uses

hashing in data strutures advanced in languae java
hashing in data strutures advanced in languae javahashing in data strutures advanced in languae java
hashing in data strutures advanced in languae java
ishasharma835109
 
5 data structures-hashtable
5 data structures-hashtable5 data structures-hashtable
5 data structures-hashtable
irdginfo
 
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
my6305874
 

Similar to Hashing algorithms and its uses (20)

hashing in data strutures advanced in languae java
hashing in data strutures advanced in languae javahashing in data strutures advanced in languae java
hashing in data strutures advanced in languae java
 
Hashing And Hashing Tables
Hashing And Hashing TablesHashing And Hashing Tables
Hashing And Hashing Tables
 
Hashing
HashingHashing
Hashing
 
Lecture14_15_Hashing.pptx
Lecture14_15_Hashing.pptxLecture14_15_Hashing.pptx
Lecture14_15_Hashing.pptx
 
Presentation.pptx
Presentation.pptxPresentation.pptx
Presentation.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
 
lecture10.ppt
lecture10.pptlecture10.ppt
lecture10.ppt
 
Hashing
HashingHashing
Hashing
 
Hash based inventory system
Hash based inventory systemHash based inventory system
Hash based inventory system
 
unit-1-dsa-hashing-2022_compressed-1-converted.pptx
unit-1-dsa-hashing-2022_compressed-1-converted.pptxunit-1-dsa-hashing-2022_compressed-1-converted.pptx
unit-1-dsa-hashing-2022_compressed-1-converted.pptx
 
asdfew.pptx
asdfew.pptxasdfew.pptx
asdfew.pptx
 
searching techniques.pptx
searching techniques.pptxsearching techniques.pptx
searching techniques.pptx
 
linear probing
linear probinglinear probing
linear probing
 
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
 
5 data structures-hashtable
5 data structures-hashtable5 data structures-hashtable
5 data structures-hashtable
 
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...
 
11_hashtable-1.ppt. Data structure algorithm
11_hashtable-1.ppt. Data structure algorithm11_hashtable-1.ppt. Data structure algorithm
11_hashtable-1.ppt. Data structure algorithm
 
Hashing
HashingHashing
Hashing
 
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
 
Hashing
HashingHashing
Hashing
 

More from Jawad Khan

More from Jawad Khan (20)

2.1 input and output in c
2.1 input and output in c2.1 input and output in c
2.1 input and output in c
 
2.2 variable arithmetics and logics
2.2 variable arithmetics and logics2.2 variable arithmetics and logics
2.2 variable arithmetics and logics
 
1.2 programming fundamentals
1.2 programming fundamentals1.2 programming fundamentals
1.2 programming fundamentals
 
1.1 programming fundamentals
1.1 programming fundamentals1.1 programming fundamentals
1.1 programming fundamentals
 
7 8. emi - analog instruments and digital instruments
7 8. emi - analog instruments and digital instruments7 8. emi - analog instruments and digital instruments
7 8. emi - analog instruments and digital instruments
 
6. emi instrument transformers (with marking)
6. emi   instrument transformers (with marking)6. emi   instrument transformers (with marking)
6. emi instrument transformers (with marking)
 
5 emi ac bridges (with marking)
5 emi  ac bridges (with marking)5 emi  ac bridges (with marking)
5 emi ac bridges (with marking)
 
4. emi potentiometer and ac bridges
4. emi  potentiometer and ac bridges4. emi  potentiometer and ac bridges
4. emi potentiometer and ac bridges
 
3 .emi wattmeter and energy meter
3 .emi   wattmeter and energy meter3 .emi   wattmeter and energy meter
3 .emi wattmeter and energy meter
 
2. emi analog electromechanical instruments
2. emi  analog electromechanical instruments2. emi  analog electromechanical instruments
2. emi analog electromechanical instruments
 
1. emi concept of measurement system
1. emi   concept of measurement system1. emi   concept of measurement system
1. emi concept of measurement system
 
Varibale frequency response lecturer 2 - audio+
Varibale frequency response   lecturer 2 - audio+Varibale frequency response   lecturer 2 - audio+
Varibale frequency response lecturer 2 - audio+
 
Variable frequency response lecture 3 - audio
Variable frequency response   lecture 3 - audioVariable frequency response   lecture 3 - audio
Variable frequency response lecture 3 - audio
 
Varibale frequency response lecturer 1 - audio
Varibale frequency response   lecturer 1 - audioVaribale frequency response   lecturer 1 - audio
Varibale frequency response lecturer 1 - audio
 
Two port network - part 3
Two port network - part 3Two port network - part 3
Two port network - part 3
 
Two port network - part 2
Two port network - part 2Two port network - part 2
Two port network - part 2
 
Two port network - part 1
Two port network - part 1Two port network - part 1
Two port network - part 1
 
4. ideal transformer and load conversion
4. ideal transformer and load conversion4. ideal transformer and load conversion
4. ideal transformer and load conversion
 
3. magnetic coupled circuits examples
3. magnetic coupled circuits examples3. magnetic coupled circuits examples
3. magnetic coupled circuits examples
 
2. magnetic coupled circuits
2. magnetic coupled circuits2. magnetic coupled circuits
2. magnetic coupled circuits
 

Recently uploaded

Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Peter Udo Diehl
 

Recently uploaded (20)

Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
The architecture of Generative AI for enterprises.pdf
The architecture of Generative AI for enterprises.pdfThe architecture of Generative AI for enterprises.pdf
The architecture of Generative AI for enterprises.pdf
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
 
What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024
 
Agentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdfAgentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdf
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1
 

Hashing algorithms and its uses

  • 1. Hashing Algorithms and its applications Introduction to data sorting and Key searching
  • 2. What is Hash table? • A faster way to access data keeping table • Also known as bucket • It can be an array of objects (that has all the data) • Requires a function to convert the real data into placing position deciding data • Can use part of the data or time/space stamp to decide the position • The position is termed as HASH
  • 3. Randomness of Data • Data can be of defined pattern and length for which we can have static length of hash table entries • Each hash table entry place is a position that is access by the key • The key is calculated by hash function • If we know the data pattern, we can easily solve all the key calculations and also know the number of rows in the has table • If the data is random, we don’t know the number of entries in the table
  • 4. Hashing Function • Calculates the key for address assignment • Key = position Hasher (Type entry) • position StoringPosition = HashTable[Key] • Here the Hasher is “to add the ASCII values of Each letter and then take modulo 11” • Folding: • A method that divides data into chunks for processing in a Hasher
  • 5. Normal allocation • The data is processed using has function • The hash that is created by the function is searched in the table • The data is placed there
  • 6.
  • 7. Collision • The Hasher gives a key that is already occupied • Normally, the old value is discarded and the new incoming data is stored • It is probable when the table space is lesser than the incoming data • Even if table data space is greater than the incoming data, this problem is probable to occur
  • 8. Solution to Collision • Open Addressing • Same level address is used but on a different location which is calculated by the user defined rule • Linear Probing (the entry is saved in the next free space) - It can create clustering • Plus 3 rehash (the key is are-calculated by adding 3 to the previous entry value) • Quadratic Probing (the entry is saved by leaving 1, 2, 4, 16 spaces on the HT) • Double Hashing (Finding the hash of the key obtained) • PreviousHashKey = Hasher(entry) • NewHash = Hasher(PreviousHashKey) • Closed Addressing • Creating chains
  • 9. Data Searching and Retrieval • The data that we want to search uses the same Hash Function • After the Hasher calculates the Key, it is given directly to the table Variable and that position has the data • Search is usually O(n) for linear search and O(log(n)) for binary search but this method makes the search operation reduced to O(1) • O(1) means that we calculated the key in a fixed time process and the we go to the Array[key] to retrieve data using fixed time again • In case of chaining, we traverse on the node to reach our data so that makes it an O(n), still faster than complete search strategy.
  • 12. A good Hash Function! • Minimum Collisions • Uniform distribution of hash values/keys (avoid clustering) • Easy to calculate Hash • Resolve the collision swiftly
  • 13. Summary • Used to index large data sets • Address of each key is calculated by the data itself • Collision resolved with open or closed addressing • Hashing is widely used in database indexing, compilers, caching, password authentication, Blockchain, etc. • Insert, Delete and retrieve occurs on a fixed time (mostly)