SlideShare una empresa de Scribd logo
1 de 21
Introduction to Hashing Techniques

Objectives
In this lesson, you will learn to:
 Randomly access data by using a hash index
 Implement Hashing function
 Define different hashing techniques
 Define collision and how collisions are handled
 Create a hash index and use it, to randomly access
  data from a file, using the key field




                       Introduction to Hashing Techniques/Lesson 8/Slide 1 of 21
  ©NIIT
Introduction to Hashing Techniques

 Hashing
  It means converting a key to an address to retrieve a
   record.
  Given a key, the offset of the record can be calculated
   with the following formula:
      Key * Record length




                    Introduction to Hashing Techniques/Lesson 8/Slide 2 of 21
  ©NIIT
Introduction to Hashing Techniques

 Hashing Functions
  Given a key, the hash function converts it into a hash
   value (location) within the range 1 -n, where n is the
   size of the storage (address) space that has been
   allocated for the records.
  The record is then retrieved at the location generated.
  Dividing is one of the commonly used hashing
   function.




                    Introduction to Hashing Techniques/Lesson 8/Slide 3 of 21
  ©NIIT
Introduction to Hashing Techniques

 Hashing Techniques
  Two hashing techniques commonly employed are:
       Hash indexes
       Hash tables
  The goal of both the techniques is same, which is as
   follows:
       To identify the location of a data record in a file
        using a key, to address transformation.




                      Introduction to Hashing Techniques/Lesson 8/Slide 4 of 21
  ©NIIT
Introduction to Hashing Techniques

 Hash Indexes
  An index created by placing keys in locations
   calculated using a hashing function is called a hash
   index file.
  It contains a key-offset pair corresponding to each
   record in the data file.
  Following two files are used in the technique
   employing hash index:
       A file containing the data records, and
       A hash index file.



                     Introduction to Hashing Techniques/Lesson 8/Slide 5 of 21
  ©NIIT
Introduction to Hashing Techniques

 Hash Tables
  Hash tables make use of data files only.
  It involves calculation of a location based on the value
   of a key.
  In this method, a whole record is inserted into the
   calculated position in the data file, i.e. the hash table.




                     Introduction to Hashing Techniques/Lesson 8/Slide 6 of 21
  ©NIIT
Introduction to Hashing Techniques

 Collisions
  An attempt to store two keys at the same position is
   known as collision.
  It will occur irrespective of the hashing function used.




                    Introduction to Hashing Techniques/Lesson 8/Slide 7 of 21
  ©NIIT
Introduction to Hashing Techniques

  Collision Processing
  Rehashing
   This method involves using a secondary hash
    function, called a rehashed function, on the hash
    value of the key.
   The rehash function is applied successively until an
    empty position is found.




                    Introduction to Hashing Techniques/Lesson 8/Slide 8 of 21
  ©NIIT
Introduction to Hashing Techniques

 Collision Processing (Contd..)
 Chaining
  This method uses links (pointers) to resolve hash
   clashes.
  Two chaining techniques are:
       Coalesed Chaining
       Separate Chaining




                   Introduction to Hashing Techniques/Lesson 8/Slide 9 of 21
  ©NIIT
Introduction to Hashing Techniques

 Coalesed Chaining
  It completely eliminates the possibility that more than
   one collision will occur even for the same hash value.
  It requires the storage area to be divided into two
   parts:
       A prime hash area
       An overflow area




                   Introduction to Hashing Techniques/Lesson 8/Slide 10 of 21
  ©NIIT
Introduction to Hashing Techniques

 Separate Chaining
  In this method, an array of header nodes is used.
  Each element in the array is a pointer, which stores
   the address of a distinct linked list.
  Each linked list is a list of records whose keys have
   the same hash values.
  When a record has to be retrieved, the hashing
   function converts the given key to yield a position
   (subscript) in the array.




                   Introduction to Hashing Techniques/Lesson 8/Slide 11 of 21
  ©NIIT
Introduction to Hashing Techniques

 Bucket Hashing
  The hashing of a key yield the position of a storage
   area in which several key entries can be stored. This
   storage area is called a bucket.
  The file is divided into a number of such buckets.
   Each bucket has enough space to store multiple
   values.
  When a record has to be retrieved, its key is hashed
   to give an offset. This offset is a bucket offset. Then
   the bucket is read into internal memory and searched
   sequentially.



                   Introduction to Hashing Techniques/Lesson 8/Slide 12 of 21
  ©NIIT
Introduction to Hashing Techniques

 Hash Indexes Vs Hash Tables
  The choice of hashing method depends on the
   following factors:
       Data Organization
       Access Speed
       Disk Space Requirement




                   Introduction to Hashing Techniques/Lesson 8/Slide 13 of 21
  ©NIIT
Introduction to Hashing Techniques

 An Example to Illustrate the Use of A Hash Table
 The assumptions made in this example are:
         The key is an alphanumeric field, the first byte
          of which is an alphabet.
         Only one key exists for a particular hash value.
         The problem of collisions is not being
          addressed.
         The file structure assumed is shown below:
          Field         Length                Type
          city           10                   String
          Population                  2                   Integer

                   Introduction to Hashing Techniques/Lesson 8/Slide 14 of 21
  ©NIIT
Introduction to Hashing Techniques

 An Example to Illustrate the Use of A Hash Table
   (Contd..)
       The hashing algorithm used is as follows: the first
        letter from the alphabetic key is extracted and the
        position of this letter in the alphabet is used as the
        hash value. If the first letter in the key is C, then
        the hash value is 3. Thus, it is obvious that the
        number of positions (or buckets) that a key might
        hash to is 26, which is the number of letters in the
        alphabet.
  The processing required to create the hash table
   involves the following steps:
       Creating file space
                     Introduction to Hashing Techniques/Lesson 8/Slide 15 of 21
  ©NIIT
Introduction to Hashing Techniques

 An Example to Illustrate the Use of A Hash Table
   (Contd..)
       Accepting Data
       Find the correct bucket
       Writing to the hash table




                    Introduction to Hashing Techniques/Lesson 8/Slide 16 of 21
  ©NIIT
Introduction to Hashing Techniques

 Problem Statement 8.D.1
  Create a hash table for records having structure given
   below:
      Field        Size
      City         10
      Population              2
      The hashing algorithm used is as follows: the first
      letter from the alphabetic is used as the hash value. If
      the first letter in the key is C, then the hash value is
      3. Thus, it is obvious that the number of positions(or
      buckets) that a key might hash to is 26, which is the
      number of letters in the alphabet.
                        Introduction to Hashing Techniques/Lesson 8/Slide 17 of 21
  ©NIIT
Introduction to Hashing Techniques

 Problem Statement 8.D.1 (Contd..)
          only one key exists for a particular hash value. In
          other words, there is only one record per bucket.
          The problem of collisions is not being addressed.
          The key is an alphanumeric field, the first byte of
          which is an alphabet.




                       Introduction to Hashing Techniques/Lesson 8/Slide 18 of 21
  ©NIIT
Introduction to Hashing Techniques

Summary
In this lesson, you learned that:
 Hashing is a technique used to access data stored in
  files
 Using hashing techniques, it is possible to calculate
  the position of a record in a data file from its key field
  value
 The main purpose of hashing is to eliminate
  unnecessary searching by using the method of direct
  access to retrieve a record. This is done by
  transforming the key to yield the offset of the record
 An algorithm called, a hashing function, is used to
  perform the key to address transformation

                      Introduction to Hashing Techniques/Lesson 8/Slide 19 of 21
   ©NIIT
Introduction to Hashing Techniques

Summary (Contd..)
 It often happens that more than one key hashes to
  the same hash value resulting in collision. AS a result,
  an attempt is made to store two records in one
  location. Collisions are processed by using various
  algorithms, three of which are:
     Rehashing
     Linked list collision processing
     Bucket hashing




                    Introduction to Hashing Techniques/Lesson 8/Slide 20 of 21
  ©NIIT
Introduction to Hashing Techniques

Summary (Contd..)
 Several hashing strategies can be employed, two of
  which are:
    Hash indexing
    Hash tables




                     Introduction to Hashing Techniques/Lesson 8/Slide 21 of 21
    ©NIIT

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Hashing data
Hashing dataHashing data
Hashing data
 
4.4 hashing
4.4 hashing4.4 hashing
4.4 hashing
 
Hashing 1
Hashing 1Hashing 1
Hashing 1
 
Hashing in datastructure
Hashing in datastructureHashing in datastructure
Hashing in datastructure
 
Hashing
HashingHashing
Hashing
 
Hashing notes data structures (HASHING AND HASH FUNCTIONS)
Hashing notes data structures (HASHING AND HASH FUNCTIONS)Hashing notes data structures (HASHING AND HASH FUNCTIONS)
Hashing notes data structures (HASHING AND HASH FUNCTIONS)
 
Hash table
Hash tableHash table
Hash table
 
Hashing PPT
Hashing PPTHashing PPT
Hashing PPT
 
Hashing
HashingHashing
Hashing
 
Hashing
HashingHashing
Hashing
 
linear probing
linear probinglinear probing
linear probing
 
Hashing algorithms and its uses
Hashing algorithms and its usesHashing algorithms and its uses
Hashing algorithms and its uses
 
Hash Tables in data Structure
Hash Tables in data StructureHash Tables in data Structure
Hash Tables in data Structure
 
Hashing
HashingHashing
Hashing
 
08 Hash Tables
08 Hash Tables08 Hash Tables
08 Hash Tables
 
Hashing
HashingHashing
Hashing
 
Hashing Algorithm
Hashing AlgorithmHashing Algorithm
Hashing Algorithm
 
Ch17 Hashing
Ch17 HashingCh17 Hashing
Ch17 Hashing
 
Hashing
HashingHashing
Hashing
 
Chapter 12 ds
Chapter 12 dsChapter 12 ds
Chapter 12 ds
 

Destacado

11 ds and algorithm session_16
11 ds and algorithm session_1611 ds and algorithm session_16
11 ds and algorithm session_16Niit Care
 
Vb.net session 09
Vb.net session 09Vb.net session 09
Vb.net session 09Niit Care
 
15 ooad uml-20
15 ooad uml-2015 ooad uml-20
15 ooad uml-20Niit Care
 
09 iec t1_s1_oo_ps_session_13
09 iec t1_s1_oo_ps_session_1309 iec t1_s1_oo_ps_session_13
09 iec t1_s1_oo_ps_session_13Niit Care
 
Jdbc session01
Jdbc session01Jdbc session01
Jdbc session01Niit Care
 
Security in the Real World - JavaOne 2013
Security in the Real World - JavaOne 2013Security in the Real World - JavaOne 2013
Security in the Real World - JavaOne 2013MattKilner
 
Probabilistic Data Structures and Approximate Solutions Oleksandr Pryymak
Probabilistic Data Structures and Approximate Solutions Oleksandr PryymakProbabilistic Data Structures and Approximate Solutions Oleksandr Pryymak
Probabilistic Data Structures and Approximate Solutions Oleksandr PryymakPyData
 
14 ooad uml-19
14 ooad uml-1914 ooad uml-19
14 ooad uml-19Niit Care
 
Deawsj 7 ppt-2_c
Deawsj 7 ppt-2_cDeawsj 7 ppt-2_c
Deawsj 7 ppt-2_cNiit Care
 
Java Garbage Collection - How it works
Java Garbage Collection - How it worksJava Garbage Collection - How it works
Java Garbage Collection - How it worksMindfire Solutions
 
Understanding Java Garbage Collection - And What You Can Do About It
Understanding Java Garbage Collection - And What You Can Do About ItUnderstanding Java Garbage Collection - And What You Can Do About It
Understanding Java Garbage Collection - And What You Can Do About ItAzul Systems Inc.
 
Aae oop xp_06
Aae oop xp_06Aae oop xp_06
Aae oop xp_06Niit Care
 
Faster persistent data structures through hashing
Faster persistent data structures through hashingFaster persistent data structures through hashing
Faster persistent data structures through hashingJohan Tibell
 

Destacado (20)

11 ds and algorithm session_16
11 ds and algorithm session_1611 ds and algorithm session_16
11 ds and algorithm session_16
 
Dacj 2-2 c
Dacj 2-2 cDacj 2-2 c
Dacj 2-2 c
 
 
Oops recap
Oops recapOops recap
Oops recap
 
Vb.net session 09
Vb.net session 09Vb.net session 09
Vb.net session 09
 
15 ooad uml-20
15 ooad uml-2015 ooad uml-20
15 ooad uml-20
 
09 iec t1_s1_oo_ps_session_13
09 iec t1_s1_oo_ps_session_1309 iec t1_s1_oo_ps_session_13
09 iec t1_s1_oo_ps_session_13
 
OOP Java
OOP JavaOOP Java
OOP Java
 
Rdbms xp 01
Rdbms xp 01Rdbms xp 01
Rdbms xp 01
 
Jdbc session01
Jdbc session01Jdbc session01
Jdbc session01
 
Computer
ComputerComputer
Computer
 
Security in the Real World - JavaOne 2013
Security in the Real World - JavaOne 2013Security in the Real World - JavaOne 2013
Security in the Real World - JavaOne 2013
 
Probabilistic Data Structures and Approximate Solutions Oleksandr Pryymak
Probabilistic Data Structures and Approximate Solutions Oleksandr PryymakProbabilistic Data Structures and Approximate Solutions Oleksandr Pryymak
Probabilistic Data Structures and Approximate Solutions Oleksandr Pryymak
 
14 ooad uml-19
14 ooad uml-1914 ooad uml-19
14 ooad uml-19
 
Deawsj 7 ppt-2_c
Deawsj 7 ppt-2_cDeawsj 7 ppt-2_c
Deawsj 7 ppt-2_c
 
Java Garbage Collection - How it works
Java Garbage Collection - How it worksJava Garbage Collection - How it works
Java Garbage Collection - How it works
 
Understanding Java Garbage Collection - And What You Can Do About It
Understanding Java Garbage Collection - And What You Can Do About ItUnderstanding Java Garbage Collection - And What You Can Do About It
Understanding Java Garbage Collection - And What You Can Do About It
 
Aae oop xp_06
Aae oop xp_06Aae oop xp_06
Aae oop xp_06
 
Dacj 1-1 a
Dacj 1-1 aDacj 1-1 a
Dacj 1-1 a
 
Faster persistent data structures through hashing
Faster persistent data structures through hashingFaster persistent data structures through hashing
Faster persistent data structures through hashing
 

Similar a Ds 8

Data Structures : hashing (1)
Data Structures : hashing (1)Data Structures : hashing (1)
Data Structures : hashing (1)Home
 
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.pptxBabaShaikh3
 
Hashing and Hash Tables
Hashing and Hash TablesHashing and Hash Tables
Hashing and Hash Tablesadil raja
 
Hashing and File Structures in Data Structure.pdf
Hashing and File Structures in Data Structure.pdfHashing and File Structures in Data Structure.pdf
Hashing and File Structures in Data Structure.pdfJaithoonBibi
 
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
 
Presentation.pptx
Presentation.pptxPresentation.pptx
Presentation.pptxAgonySingh
 
Bloom Filters: An Introduction
Bloom Filters: An IntroductionBloom Filters: An Introduction
Bloom Filters: An IntroductionIRJET Journal
 
Hashing.pptx
Hashing.pptxHashing.pptx
Hashing.pptxkratika64
 
Implementação do Hash Coalha/Coalesced
Implementação do Hash Coalha/CoalescedImplementação do Hash Coalha/Coalesced
Implementação do Hash Coalha/CoalescedCriatividadeZeroDocs
 
Chapter 10: hashing data structure
Chapter 10:  hashing data structureChapter 10:  hashing data structure
Chapter 10: hashing data structureMahmoud Alfarra
 
introduction to trees,graphs,hashing
introduction to trees,graphs,hashingintroduction to trees,graphs,hashing
introduction to trees,graphs,hashingAkhil Prem
 
Performance Analysis of Hashing Mathods on the Employment of App
Performance Analysis of Hashing Mathods on the Employment of App Performance Analysis of Hashing Mathods on the Employment of App
Performance Analysis of Hashing Mathods on the Employment of App IJECEIAES
 
Data Structure and Algorithms: What is Hash Table ppt
Data Structure and Algorithms: What is Hash Table pptData Structure and Algorithms: What is Hash Table ppt
Data Structure and Algorithms: What is Hash Table pptJUSTFUN40
 
11. Hashing - Data Structures using C++ by Varsha Patil
11. Hashing - Data Structures using C++ by Varsha Patil11. Hashing - Data Structures using C++ by Varsha Patil
11. Hashing - Data Structures using C++ by Varsha Patilwidespreadpromotion
 
Similarity-preserving hash for content-based audio retrieval using unsupervis...
Similarity-preserving hash for content-based audio retrieval using unsupervis...Similarity-preserving hash for content-based audio retrieval using unsupervis...
Similarity-preserving hash for content-based audio retrieval using unsupervis...IJECEIAES
 
Hashing And Hashing Tables
Hashing And Hashing TablesHashing And Hashing Tables
Hashing And Hashing TablesChinmaya M. N
 

Similar a Ds 8 (20)

asdfew.pptx
asdfew.pptxasdfew.pptx
asdfew.pptx
 
Data Structures : hashing (1)
Data Structures : hashing (1)Data Structures : hashing (1)
Data Structures : hashing (1)
 
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
 
Hashing and Hash Tables
Hashing and Hash TablesHashing and Hash Tables
Hashing and Hash Tables
 
Hashing
HashingHashing
Hashing
 
Hashing and File Structures in Data Structure.pdf
Hashing and File Structures in Data Structure.pdfHashing and File Structures in Data Structure.pdf
Hashing and File Structures in Data Structure.pdf
 
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
 
Presentation.pptx
Presentation.pptxPresentation.pptx
Presentation.pptx
 
Bloom Filters: An Introduction
Bloom Filters: An IntroductionBloom Filters: An Introduction
Bloom Filters: An Introduction
 
Hashing.pptx
Hashing.pptxHashing.pptx
Hashing.pptx
 
Implementação do Hash Coalha/Coalesced
Implementação do Hash Coalha/CoalescedImplementação do Hash Coalha/Coalesced
Implementação do Hash Coalha/Coalesced
 
Chapter 10: hashing data structure
Chapter 10:  hashing data structureChapter 10:  hashing data structure
Chapter 10: hashing data structure
 
introduction to trees,graphs,hashing
introduction to trees,graphs,hashingintroduction to trees,graphs,hashing
introduction to trees,graphs,hashing
 
Performance Analysis of Hashing Mathods on the Employment of App
Performance Analysis of Hashing Mathods on the Employment of App Performance Analysis of Hashing Mathods on the Employment of App
Performance Analysis of Hashing Mathods on the Employment of App
 
Data Structure and Algorithms: What is Hash Table ppt
Data Structure and Algorithms: What is Hash Table pptData Structure and Algorithms: What is Hash Table ppt
Data Structure and Algorithms: What is Hash Table ppt
 
11. Hashing - Data Structures using C++ by Varsha Patil
11. Hashing - Data Structures using C++ by Varsha Patil11. Hashing - Data Structures using C++ by Varsha Patil
11. Hashing - Data Structures using C++ by Varsha Patil
 
Hash pre
Hash preHash pre
Hash pre
 
Similarity-preserving hash for content-based audio retrieval using unsupervis...
Similarity-preserving hash for content-based audio retrieval using unsupervis...Similarity-preserving hash for content-based audio retrieval using unsupervis...
Similarity-preserving hash for content-based audio retrieval using unsupervis...
 
DS THEORY 35.pptx
DS THEORY 35.pptxDS THEORY 35.pptx
DS THEORY 35.pptx
 
Hashing And Hashing Tables
Hashing And Hashing TablesHashing And Hashing Tables
Hashing And Hashing Tables
 

Más de Niit Care (20)

Ajs 1 b
Ajs 1 bAjs 1 b
Ajs 1 b
 
Ajs 4 b
Ajs 4 bAjs 4 b
Ajs 4 b
 
Ajs 4 a
Ajs 4 aAjs 4 a
Ajs 4 a
 
Ajs 4 c
Ajs 4 cAjs 4 c
Ajs 4 c
 
Ajs 3 b
Ajs 3 bAjs 3 b
Ajs 3 b
 
Ajs 3 a
Ajs 3 aAjs 3 a
Ajs 3 a
 
Ajs 3 c
Ajs 3 cAjs 3 c
Ajs 3 c
 
Ajs 2 b
Ajs 2 bAjs 2 b
Ajs 2 b
 
Ajs 2 a
Ajs 2 aAjs 2 a
Ajs 2 a
 
Ajs 2 c
Ajs 2 cAjs 2 c
Ajs 2 c
 
Ajs 1 a
Ajs 1 aAjs 1 a
Ajs 1 a
 
Ajs 1 c
Ajs 1 cAjs 1 c
Ajs 1 c
 
Dacj 4 2-c
Dacj 4 2-cDacj 4 2-c
Dacj 4 2-c
 
Dacj 4 2-b
Dacj 4 2-bDacj 4 2-b
Dacj 4 2-b
 
Dacj 4 2-a
Dacj 4 2-aDacj 4 2-a
Dacj 4 2-a
 
Dacj 4 1-c
Dacj 4 1-cDacj 4 1-c
Dacj 4 1-c
 
Dacj 4 1-b
Dacj 4 1-bDacj 4 1-b
Dacj 4 1-b
 
Dacj 4 1-a
Dacj 4 1-aDacj 4 1-a
Dacj 4 1-a
 
Dacj 1-2 b
Dacj 1-2 bDacj 1-2 b
Dacj 1-2 b
 
Dacj 1-3 c
Dacj 1-3 cDacj 1-3 c
Dacj 1-3 c
 

Último

Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 

Último (20)

Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 

Ds 8

  • 1. Introduction to Hashing Techniques Objectives In this lesson, you will learn to: Randomly access data by using a hash index Implement Hashing function Define different hashing techniques Define collision and how collisions are handled Create a hash index and use it, to randomly access data from a file, using the key field Introduction to Hashing Techniques/Lesson 8/Slide 1 of 21 ©NIIT
  • 2. Introduction to Hashing Techniques Hashing It means converting a key to an address to retrieve a record. Given a key, the offset of the record can be calculated with the following formula: Key * Record length Introduction to Hashing Techniques/Lesson 8/Slide 2 of 21 ©NIIT
  • 3. Introduction to Hashing Techniques Hashing Functions Given a key, the hash function converts it into a hash value (location) within the range 1 -n, where n is the size of the storage (address) space that has been allocated for the records. The record is then retrieved at the location generated. Dividing is one of the commonly used hashing function. Introduction to Hashing Techniques/Lesson 8/Slide 3 of 21 ©NIIT
  • 4. Introduction to Hashing Techniques Hashing Techniques Two hashing techniques commonly employed are: Hash indexes Hash tables The goal of both the techniques is same, which is as follows: To identify the location of a data record in a file using a key, to address transformation. Introduction to Hashing Techniques/Lesson 8/Slide 4 of 21 ©NIIT
  • 5. Introduction to Hashing Techniques Hash Indexes An index created by placing keys in locations calculated using a hashing function is called a hash index file. It contains a key-offset pair corresponding to each record in the data file. Following two files are used in the technique employing hash index: A file containing the data records, and A hash index file. Introduction to Hashing Techniques/Lesson 8/Slide 5 of 21 ©NIIT
  • 6. Introduction to Hashing Techniques Hash Tables Hash tables make use of data files only. It involves calculation of a location based on the value of a key. In this method, a whole record is inserted into the calculated position in the data file, i.e. the hash table. Introduction to Hashing Techniques/Lesson 8/Slide 6 of 21 ©NIIT
  • 7. Introduction to Hashing Techniques Collisions An attempt to store two keys at the same position is known as collision. It will occur irrespective of the hashing function used. Introduction to Hashing Techniques/Lesson 8/Slide 7 of 21 ©NIIT
  • 8. Introduction to Hashing Techniques Collision Processing Rehashing This method involves using a secondary hash function, called a rehashed function, on the hash value of the key. The rehash function is applied successively until an empty position is found. Introduction to Hashing Techniques/Lesson 8/Slide 8 of 21 ©NIIT
  • 9. Introduction to Hashing Techniques Collision Processing (Contd..) Chaining This method uses links (pointers) to resolve hash clashes. Two chaining techniques are: Coalesed Chaining Separate Chaining Introduction to Hashing Techniques/Lesson 8/Slide 9 of 21 ©NIIT
  • 10. Introduction to Hashing Techniques Coalesed Chaining It completely eliminates the possibility that more than one collision will occur even for the same hash value. It requires the storage area to be divided into two parts: A prime hash area An overflow area Introduction to Hashing Techniques/Lesson 8/Slide 10 of 21 ©NIIT
  • 11. Introduction to Hashing Techniques Separate Chaining In this method, an array of header nodes is used. Each element in the array is a pointer, which stores the address of a distinct linked list. Each linked list is a list of records whose keys have the same hash values. When a record has to be retrieved, the hashing function converts the given key to yield a position (subscript) in the array. Introduction to Hashing Techniques/Lesson 8/Slide 11 of 21 ©NIIT
  • 12. Introduction to Hashing Techniques Bucket Hashing The hashing of a key yield the position of a storage area in which several key entries can be stored. This storage area is called a bucket. The file is divided into a number of such buckets. Each bucket has enough space to store multiple values. When a record has to be retrieved, its key is hashed to give an offset. This offset is a bucket offset. Then the bucket is read into internal memory and searched sequentially. Introduction to Hashing Techniques/Lesson 8/Slide 12 of 21 ©NIIT
  • 13. Introduction to Hashing Techniques Hash Indexes Vs Hash Tables The choice of hashing method depends on the following factors: Data Organization Access Speed Disk Space Requirement Introduction to Hashing Techniques/Lesson 8/Slide 13 of 21 ©NIIT
  • 14. Introduction to Hashing Techniques An Example to Illustrate the Use of A Hash Table The assumptions made in this example are: The key is an alphanumeric field, the first byte of which is an alphabet. Only one key exists for a particular hash value. The problem of collisions is not being addressed. The file structure assumed is shown below: Field Length Type city 10 String Population 2 Integer Introduction to Hashing Techniques/Lesson 8/Slide 14 of 21 ©NIIT
  • 15. Introduction to Hashing Techniques An Example to Illustrate the Use of A Hash Table (Contd..) The hashing algorithm used is as follows: the first letter from the alphabetic key is extracted and the position of this letter in the alphabet is used as the hash value. If the first letter in the key is C, then the hash value is 3. Thus, it is obvious that the number of positions (or buckets) that a key might hash to is 26, which is the number of letters in the alphabet. The processing required to create the hash table involves the following steps: Creating file space Introduction to Hashing Techniques/Lesson 8/Slide 15 of 21 ©NIIT
  • 16. Introduction to Hashing Techniques An Example to Illustrate the Use of A Hash Table (Contd..) Accepting Data Find the correct bucket Writing to the hash table Introduction to Hashing Techniques/Lesson 8/Slide 16 of 21 ©NIIT
  • 17. Introduction to Hashing Techniques Problem Statement 8.D.1 Create a hash table for records having structure given below: Field Size City 10 Population 2 The hashing algorithm used is as follows: the first letter from the alphabetic is used as the hash value. If the first letter in the key is C, then the hash value is 3. Thus, it is obvious that the number of positions(or buckets) that a key might hash to is 26, which is the number of letters in the alphabet. Introduction to Hashing Techniques/Lesson 8/Slide 17 of 21 ©NIIT
  • 18. Introduction to Hashing Techniques Problem Statement 8.D.1 (Contd..) only one key exists for a particular hash value. In other words, there is only one record per bucket. The problem of collisions is not being addressed. The key is an alphanumeric field, the first byte of which is an alphabet. Introduction to Hashing Techniques/Lesson 8/Slide 18 of 21 ©NIIT
  • 19. Introduction to Hashing Techniques Summary In this lesson, you learned that: Hashing is a technique used to access data stored in files Using hashing techniques, it is possible to calculate the position of a record in a data file from its key field value The main purpose of hashing is to eliminate unnecessary searching by using the method of direct access to retrieve a record. This is done by transforming the key to yield the offset of the record An algorithm called, a hashing function, is used to perform the key to address transformation Introduction to Hashing Techniques/Lesson 8/Slide 19 of 21 ©NIIT
  • 20. Introduction to Hashing Techniques Summary (Contd..) It often happens that more than one key hashes to the same hash value resulting in collision. AS a result, an attempt is made to store two records in one location. Collisions are processed by using various algorithms, three of which are: Rehashing Linked list collision processing Bucket hashing Introduction to Hashing Techniques/Lesson 8/Slide 20 of 21 ©NIIT
  • 21. Introduction to Hashing Techniques Summary (Contd..) Several hashing strategies can be employed, two of which are: Hash indexing Hash tables Introduction to Hashing Techniques/Lesson 8/Slide 21 of 21 ©NIIT

Notas del editor

  1. Lower Bound and Upper Bound to denote the first element number and the last element number respectively
  2. Lower Bound and Upper Bound to denote the first element number and the last element number respectively