SlideShare a Scribd company logo
1 of 24
Download to read offline
Introduction Hashing Techniques Applications
HASHING
Muhammad Adil Raja
Introduction Hashing Techniques Applications
OUTLINE
1 INTRODUCTION
2 HASHING TECHNIQUES
3 APPLICATIONS
Introduction Hashing Techniques Applications
OUTLINE
1 INTRODUCTION
2 HASHING TECHNIQUES
3 APPLICATIONS
Introduction Hashing Techniques Applications
OUTLINE
1 INTRODUCTION
2 HASHING TECHNIQUES
3 APPLICATIONS
Introduction Hashing Techniques Applications
HASHING
The idea of hashing is to distribute the entries of a dataset
across an array of buckets.
Given a key, the algorithm computes an index that
suggests where an entry can be found:
index = f(key, array_size)
Often this is done in two steps:
hash = hashfunc(key).
index = hash % array_size
Introduction Hashing Techniques Applications
WHAT IS HASHING
A Hash Table
A data structure to implement an associative array.
A structure that can map keys to values.
Uses a hash function to compute an index into an array of
buckets or slots from which the correct value can be found.
Introduction Hashing Techniques Applications
HASHING TECHNIQUES
Separate Chaining.
Open Addressing.
Coalesced Hashing.
....
Introduction Hashing Techniques Applications
HASH FUNCTION
Crucial for good hash table performance.
Can be difficult to achieve.
A basic expectation is that the function would provide a
uniform distribution of hash values.
A non-uniform distribution increases the number of
collisions and the cost of resolving them.
Introduction Hashing Techniques Applications
COLLISION RESOLUTION
Practically unavoidable.
Birthday problem.
Introduction Hashing Techniques Applications
SEPARATE CHAINING
Every bucket is independent.
And maintains a list of entries with the same index.
Time for hash function operations depends on the time to
find the bucket (constant) and the time for list operations.
The technique is also called open hashing or closed
addressing.
In a good hash table every bucket has very few entries.
Introduction Hashing Techniques Applications
SEPARATE CHAINING
FIGURE: Pause
Introduction Hashing Techniques Applications
SEPARATE CHAINING WITH LINKED LISTS
Popular as they require basic data structures with simple
algorithms.
They can use simple hash functions that are unsuitable for
other methods.
Cost of the table operation depends on the size of the
selected bucket for the desired key.
The worst case scenario is when all the entries are
inserted into the same bucket.
Introduction Hashing Techniques Applications
SEPARATE CHAINING WITH OTHER DATA STRUCTURES
AVL Trees.
BSTs.
Dynamic Arrays.
Introduction Hashing Techniques Applications
TIME COMPLEXITY MEASURES
TABLE: Time Complexity Measures
Guarantee Average Case
Implementation Search Insert Delete Search Insert Delete
Unordered Array N N N N/2 N/2 N/2
Ordered Array lg N N N lg N N/2 N/2
Unordered List N N N N/2 N N/2
Ordered List N N N N/2 N/2 N/2
BST N N N 1.39 lg N 1.39 lg N ?
Randomized BST 7 lg N 7 lg N 7 lg N 1.39 lg N 1.39 lg N 1.39 lg N
Introduction Hashing Techniques Applications
OPEN ADDRESSING (CLOSED HASHING)
All entry records are stored in the bucket array itself.
Insertion of a new entry: The buckets are examined,
starting from the hashed-to slot and proceeding in some
probe sequence, until an unoccupied slot is found.
Searching: The buckets are scanned in the same
sequence, until the target entry is found, or an unused slot
is found, which indicates that there is no such key in the
table.
Open Addressing: Refers to the fact that location (address)
of an entry is not determined by its hash value.
Closed Hashing: Not to be confused with open hashing or
close addressing -> names reserved for separate chaining.
Introduction Hashing Techniques Applications
PROBE SEQUENCES
Linear Probing – A fixed interval between probes (usually
1).
Quadratic Probing – Interval between probes is increased
by adding the successive outputs of a quadratic polynomial
to the starting value given by the original computation.
Double Hashing – Interval between probes is computed by
another hash function.
Drawback: The number of stored entries cannot exceed
the number of slots in the bucket array.
Introduction Hashing Techniques Applications
OPEN ADDRESSING
Introduction Hashing Techniques Applications
LOAD FACTOR – A KEY STATISTIC
Number of entries divided by the number of buckets – n/k.
If this grows too large the hash table becomes slow.
Variance of number of entires per bucket is important.
Two tables have 1000 entries and 1000 buckets.
One has one entry in one bucket and the second has all
the entries in one bucket.
Hashing is not working in the second hash table.
A low load factor is not beneficial.
As the load factor approaches 0, the proportion of unused
areas in the hash table increases.
This does not necessarily reduce the search cost.
This results in wasted memory.
Introduction Hashing Techniques Applications
HOW DROPBOX KNOWS YOU ARE SHARING
COPYRIGHTED STUFF
Dropbox checks the hash of a shared file against a banned
list, and blocks the share if there is a match.
With a properly implemented hash function, running the
same exact file through the algorithm twice will return the
same identifier both times – but changing a file even
slightly completely changes the hash.
This identifier can be used to tell you if a file is exactly the
same as another file – but it is a one way street.
The hash couldn’t tell you what that original file is, without
you already knowing or having a copy of the file to
compare it to.
Introduction Hashing Techniques Applications
DROPBOX
FIGURE: Pause
Introduction Hashing Techniques Applications
DROPBOX
When you upload a file to Dropbox, two things happen to it:
a hash is generated, and then the file gets encrypted to
keep any unauthorized user (be it a hacker or a Dropbox
employee) who somehow stumbles it sitting on Dropbox’s
servers from easily being able to open it up.
After a DMCA complaint is verified by Dropbox’s legal
team, Dropbox adds that file’s hash to a big blacklist of
hashes known to be those corresponding to files they can’t
legally allow to be shared. When you share a link to a file,
it checks that file’s hash against the blacklist.
If the file you are sharing is the exact same file that a
copyright holder complained about, it is blocked from being
shared with others. If it is something else – a new file, or
even a modified version of the same file – a hash-based
anti-infringement system should not have any idea what it
is looking at.
Introduction Hashing Techniques Applications
SUBTREE CACHING (IN SYMBOLIC REGRESSION)
log
log
tan z
+
y
x * (tan y + z ) log (x + yz )
*
x +
*
x *
y z
parents
Functions
subtrees selected randomly for crossover
Introduction Hashing Techniques Applications
SUBTREE CACHING
Every subtree is evaluated and cached, along with its
evaluation.
As a new tree arrives, its subtrees are supposed to be
evaluated recursively.
Before evaluation, the cache is checked for an evaluation
of a matching subtree.
If found, evaluation is kept. If not found, the new subtree is
evaluated and its evaluation is stored in the cache.
Improves performance by saving time on unnecessary
evaluations.
Introduction Hashing Techniques Applications
THANKYOU

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)

Ch17 Hashing
Ch17 HashingCh17 Hashing
Ch17 Hashing
 
Extensible hashing
Extensible hashingExtensible hashing
Extensible hashing
 
Hashing in datastructure
Hashing in datastructureHashing in datastructure
Hashing in datastructure
 
4.4 hashing
4.4 hashing4.4 hashing
4.4 hashing
 
Hashing algorithms and its uses
Hashing algorithms and its usesHashing algorithms and its uses
Hashing algorithms and its uses
 
Quadratic probing
Quadratic probingQuadratic probing
Quadratic probing
 
Python strings presentation
Python strings presentationPython strings presentation
Python strings presentation
 
Lec 17 heap data structure
Lec 17 heap data structureLec 17 heap data structure
Lec 17 heap data structure
 
Shell sorting
Shell sortingShell sorting
Shell sorting
 
Hash table in data structure and algorithm
Hash table in data structure and algorithmHash table in data structure and algorithm
Hash table in data structure and algorithm
 
Data structure by Digvijay
Data structure by DigvijayData structure by Digvijay
Data structure by Digvijay
 
Hashing
HashingHashing
Hashing
 
Threaded Binary Tree.pptx
Threaded Binary Tree.pptxThreaded Binary Tree.pptx
Threaded Binary Tree.pptx
 
Hashing
HashingHashing
Hashing
 
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
 
Bubble sort | Data structure |
Bubble sort | Data structure |Bubble sort | Data structure |
Bubble sort | Data structure |
 
Rehashing
RehashingRehashing
Rehashing
 
Hashing
HashingHashing
Hashing
 
Heap sort
Heap sortHeap sort
Heap sort
 
Hash table
Hash tableHash table
Hash table
 

Viewers also liked

Data structure and algorithms in c++
Data structure and algorithms in c++Data structure and algorithms in c++
Data structure and algorithms in c++
Karmjeet Chahal
 
12 couplingand cohesion-student
12 couplingand cohesion-student12 couplingand cohesion-student
12 couplingand cohesion-student
randhirlpu
 
C++: inheritance, composition, polymorphism
C++: inheritance, composition, polymorphismC++: inheritance, composition, polymorphism
C++: inheritance, composition, polymorphism
Jussi Pohjolainen
 

Viewers also liked (20)

Association agggregation and composition
Association agggregation and compositionAssociation agggregation and composition
Association agggregation and composition
 
04 design concepts_n_principles
04 design concepts_n_principles04 design concepts_n_principles
04 design concepts_n_principles
 
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
 
The Physical Layer
The Physical LayerThe Physical Layer
The Physical Layer
 
Classes And Methods
Classes And MethodsClasses And Methods
Classes And Methods
 
Data structure and algorithms in c++
Data structure and algorithms in c++Data structure and algorithms in c++
Data structure and algorithms in c++
 
The Data Link Layer
The Data Link LayerThe Data Link Layer
The Data Link Layer
 
C++ Inheritance
C++ InheritanceC++ Inheritance
C++ Inheritance
 
Polymorphism and Software Reuse
Polymorphism and Software ReusePolymorphism and Software Reuse
Polymorphism and Software Reuse
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Universal Declarative Services
Universal Declarative ServicesUniversal Declarative Services
Universal Declarative Services
 
12 couplingand cohesion-student
12 couplingand cohesion-student12 couplingand cohesion-student
12 couplingand cohesion-student
 
Syntax part 6
Syntax part 6Syntax part 6
Syntax part 6
 
Iterator - a powerful but underappreciated design pattern
Iterator - a powerful but underappreciated design patternIterator - a powerful but underappreciated design pattern
Iterator - a powerful but underappreciated design pattern
 
XKE - Programming Paradigms & Constructs
XKE - Programming Paradigms & ConstructsXKE - Programming Paradigms & Constructs
XKE - Programming Paradigms & Constructs
 
C++: inheritance, composition, polymorphism
C++: inheritance, composition, polymorphismC++: inheritance, composition, polymorphism
C++: inheritance, composition, polymorphism
 
WSO2 Complex Event Processor
WSO2 Complex Event ProcessorWSO2 Complex Event Processor
WSO2 Complex Event Processor
 
Cohesion and coherence
Cohesion and coherenceCohesion and coherence
Cohesion and coherence
 
Cohesion & Coupling
Cohesion & Coupling Cohesion & Coupling
Cohesion & Coupling
 
The Network Layer
The Network LayerThe Network Layer
The Network Layer
 

Similar to Hashing and Hash Tables

Data Step Hash Object vs SQL Join
Data Step Hash Object vs SQL JoinData Step Hash Object vs SQL Join
Data Step Hash Object vs SQL Join
Geoff Ness
 

Similar to Hashing and Hash Tables (20)

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
 
Chapter 10: hashing data structure
Chapter 10:  hashing data structureChapter 10:  hashing data structure
Chapter 10: hashing data structure
 
Hashing
HashingHashing
Hashing
 
introduction to trees,graphs,hashing
introduction to trees,graphs,hashingintroduction to trees,graphs,hashing
introduction to trees,graphs,hashing
 
Ds 8
Ds 8Ds 8
Ds 8
 
Chapter 12 ds
Chapter 12 dsChapter 12 ds
Chapter 12 ds
 
Real-time Data De-duplication using Locality-sensitive Hashing powered by Sto...
Real-time Data De-duplication using Locality-sensitive Hashing powered by Sto...Real-time Data De-duplication using Locality-sensitive Hashing powered by Sto...
Real-time Data De-duplication using Locality-sensitive Hashing powered by Sto...
 
Hashing And Hashing Tables
Hashing And Hashing TablesHashing And Hashing Tables
Hashing And Hashing Tables
 
Data Structures : hashing (1)
Data Structures : hashing (1)Data Structures : hashing (1)
Data Structures : hashing (1)
 
Presentation.pptx
Presentation.pptxPresentation.pptx
Presentation.pptx
 
Data Step Hash Object vs SQL Join
Data Step Hash Object vs SQL JoinData Step Hash Object vs SQL Join
Data Step Hash Object vs SQL Join
 
Distributed Caching - Cache Unleashed
Distributed Caching - Cache UnleashedDistributed Caching - Cache Unleashed
Distributed Caching - Cache Unleashed
 
Ts project Hash based inventory system
Ts project Hash based inventory systemTs project Hash based inventory system
Ts project Hash based inventory system
 
Hash pre
Hash preHash pre
Hash pre
 
VCE Unit 04vv.pptx
VCE Unit 04vv.pptxVCE Unit 04vv.pptx
VCE Unit 04vv.pptx
 
linear probing
linear probinglinear probing
linear probing
 
Bloom Filters: An Introduction
Bloom Filters: An IntroductionBloom Filters: An Introduction
Bloom Filters: An Introduction
 
Hive query optimization infinity
Hive query optimization infinityHive query optimization infinity
Hive query optimization infinity
 
Algorithms notes tutorials duniya
Algorithms notes   tutorials duniyaAlgorithms notes   tutorials duniya
Algorithms notes tutorials duniya
 

More from adil raja

More from adil raja (20)

ANNs.pdf
ANNs.pdfANNs.pdf
ANNs.pdf
 
A Software Requirements Specification
A Software Requirements SpecificationA Software Requirements Specification
A Software Requirements Specification
 
NUAV - A Testbed for Development of Autonomous Unmanned Aerial Vehicles
NUAV - A Testbed for Development of Autonomous Unmanned Aerial VehiclesNUAV - A Testbed for Development of Autonomous Unmanned Aerial Vehicles
NUAV - A Testbed for Development of Autonomous Unmanned Aerial Vehicles
 
DevOps Demystified
DevOps DemystifiedDevOps Demystified
DevOps Demystified
 
On Research (And Development)
On Research (And Development)On Research (And Development)
On Research (And Development)
 
Simulators as Drivers of Cutting Edge Research
Simulators as Drivers of Cutting Edge ResearchSimulators as Drivers of Cutting Edge Research
Simulators as Drivers of Cutting Edge Research
 
The Knock Knock Protocol
The Knock Knock ProtocolThe Knock Knock Protocol
The Knock Knock Protocol
 
File Transfer Through Sockets
File Transfer Through SocketsFile Transfer Through Sockets
File Transfer Through Sockets
 
Remote Command Execution
Remote Command ExecutionRemote Command Execution
Remote Command Execution
 
Thesis
ThesisThesis
Thesis
 
CMM Level 3 Assessment of Xavor Pakistan
CMM Level 3 Assessment of Xavor PakistanCMM Level 3 Assessment of Xavor Pakistan
CMM Level 3 Assessment of Xavor Pakistan
 
Data Warehousing
Data WarehousingData Warehousing
Data Warehousing
 
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
 
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
 
Real-Time Non-Intrusive Speech Quality Estimation for VoIP
Real-Time Non-Intrusive Speech Quality Estimation for VoIPReal-Time Non-Intrusive Speech Quality Estimation for VoIP
Real-Time Non-Intrusive Speech Quality Estimation for VoIP
 
VoIP
VoIPVoIP
VoIP
 
ULMAN GUI Specifications
ULMAN GUI SpecificationsULMAN GUI Specifications
ULMAN GUI Specifications
 
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
 
ULMAN-GUI
ULMAN-GUIULMAN-GUI
ULMAN-GUI
 
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
 

Recently uploaded

Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
MsecMca
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
Epec Engineered Technologies
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdf
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 

Hashing and Hash Tables

  • 1. Introduction Hashing Techniques Applications HASHING Muhammad Adil Raja
  • 2. Introduction Hashing Techniques Applications OUTLINE 1 INTRODUCTION 2 HASHING TECHNIQUES 3 APPLICATIONS
  • 3. Introduction Hashing Techniques Applications OUTLINE 1 INTRODUCTION 2 HASHING TECHNIQUES 3 APPLICATIONS
  • 4. Introduction Hashing Techniques Applications OUTLINE 1 INTRODUCTION 2 HASHING TECHNIQUES 3 APPLICATIONS
  • 5. Introduction Hashing Techniques Applications HASHING The idea of hashing is to distribute the entries of a dataset across an array of buckets. Given a key, the algorithm computes an index that suggests where an entry can be found: index = f(key, array_size) Often this is done in two steps: hash = hashfunc(key). index = hash % array_size
  • 6. Introduction Hashing Techniques Applications WHAT IS HASHING A Hash Table A data structure to implement an associative array. A structure that can map keys to values. Uses a hash function to compute an index into an array of buckets or slots from which the correct value can be found.
  • 7. Introduction Hashing Techniques Applications HASHING TECHNIQUES Separate Chaining. Open Addressing. Coalesced Hashing. ....
  • 8. Introduction Hashing Techniques Applications HASH FUNCTION Crucial for good hash table performance. Can be difficult to achieve. A basic expectation is that the function would provide a uniform distribution of hash values. A non-uniform distribution increases the number of collisions and the cost of resolving them.
  • 9. Introduction Hashing Techniques Applications COLLISION RESOLUTION Practically unavoidable. Birthday problem.
  • 10. Introduction Hashing Techniques Applications SEPARATE CHAINING Every bucket is independent. And maintains a list of entries with the same index. Time for hash function operations depends on the time to find the bucket (constant) and the time for list operations. The technique is also called open hashing or closed addressing. In a good hash table every bucket has very few entries.
  • 11. Introduction Hashing Techniques Applications SEPARATE CHAINING FIGURE: Pause
  • 12. Introduction Hashing Techniques Applications SEPARATE CHAINING WITH LINKED LISTS Popular as they require basic data structures with simple algorithms. They can use simple hash functions that are unsuitable for other methods. Cost of the table operation depends on the size of the selected bucket for the desired key. The worst case scenario is when all the entries are inserted into the same bucket.
  • 13. Introduction Hashing Techniques Applications SEPARATE CHAINING WITH OTHER DATA STRUCTURES AVL Trees. BSTs. Dynamic Arrays.
  • 14. Introduction Hashing Techniques Applications TIME COMPLEXITY MEASURES TABLE: Time Complexity Measures Guarantee Average Case Implementation Search Insert Delete Search Insert Delete Unordered Array N N N N/2 N/2 N/2 Ordered Array lg N N N lg N N/2 N/2 Unordered List N N N N/2 N N/2 Ordered List N N N N/2 N/2 N/2 BST N N N 1.39 lg N 1.39 lg N ? Randomized BST 7 lg N 7 lg N 7 lg N 1.39 lg N 1.39 lg N 1.39 lg N
  • 15. Introduction Hashing Techniques Applications OPEN ADDRESSING (CLOSED HASHING) All entry records are stored in the bucket array itself. Insertion of a new entry: The buckets are examined, starting from the hashed-to slot and proceeding in some probe sequence, until an unoccupied slot is found. Searching: The buckets are scanned in the same sequence, until the target entry is found, or an unused slot is found, which indicates that there is no such key in the table. Open Addressing: Refers to the fact that location (address) of an entry is not determined by its hash value. Closed Hashing: Not to be confused with open hashing or close addressing -> names reserved for separate chaining.
  • 16. Introduction Hashing Techniques Applications PROBE SEQUENCES Linear Probing – A fixed interval between probes (usually 1). Quadratic Probing – Interval between probes is increased by adding the successive outputs of a quadratic polynomial to the starting value given by the original computation. Double Hashing – Interval between probes is computed by another hash function. Drawback: The number of stored entries cannot exceed the number of slots in the bucket array.
  • 17. Introduction Hashing Techniques Applications OPEN ADDRESSING
  • 18. Introduction Hashing Techniques Applications LOAD FACTOR – A KEY STATISTIC Number of entries divided by the number of buckets – n/k. If this grows too large the hash table becomes slow. Variance of number of entires per bucket is important. Two tables have 1000 entries and 1000 buckets. One has one entry in one bucket and the second has all the entries in one bucket. Hashing is not working in the second hash table. A low load factor is not beneficial. As the load factor approaches 0, the proportion of unused areas in the hash table increases. This does not necessarily reduce the search cost. This results in wasted memory.
  • 19. Introduction Hashing Techniques Applications HOW DROPBOX KNOWS YOU ARE SHARING COPYRIGHTED STUFF Dropbox checks the hash of a shared file against a banned list, and blocks the share if there is a match. With a properly implemented hash function, running the same exact file through the algorithm twice will return the same identifier both times – but changing a file even slightly completely changes the hash. This identifier can be used to tell you if a file is exactly the same as another file – but it is a one way street. The hash couldn’t tell you what that original file is, without you already knowing or having a copy of the file to compare it to.
  • 20. Introduction Hashing Techniques Applications DROPBOX FIGURE: Pause
  • 21. Introduction Hashing Techniques Applications DROPBOX When you upload a file to Dropbox, two things happen to it: a hash is generated, and then the file gets encrypted to keep any unauthorized user (be it a hacker or a Dropbox employee) who somehow stumbles it sitting on Dropbox’s servers from easily being able to open it up. After a DMCA complaint is verified by Dropbox’s legal team, Dropbox adds that file’s hash to a big blacklist of hashes known to be those corresponding to files they can’t legally allow to be shared. When you share a link to a file, it checks that file’s hash against the blacklist. If the file you are sharing is the exact same file that a copyright holder complained about, it is blocked from being shared with others. If it is something else – a new file, or even a modified version of the same file – a hash-based anti-infringement system should not have any idea what it is looking at.
  • 22. Introduction Hashing Techniques Applications SUBTREE CACHING (IN SYMBOLIC REGRESSION) log log tan z + y x * (tan y + z ) log (x + yz ) * x + * x * y z parents Functions subtrees selected randomly for crossover
  • 23. Introduction Hashing Techniques Applications SUBTREE CACHING Every subtree is evaluated and cached, along with its evaluation. As a new tree arrives, its subtrees are supposed to be evaluated recursively. Before evaluation, the cache is checked for an evaluation of a matching subtree. If found, evaluation is kept. If not found, the new subtree is evaluated and its evaluation is stored in the cache. Improves performance by saving time on unnecessary evaluations.
  • 24. Introduction Hashing Techniques Applications THANKYOU