Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

What is Hashing?, Lecture notes of Data Structures and Algorithms

A hash is an into mapping of some input. (number, string) into a usually small and usually integer number. • The input is the hash key.

Typology: Lecture notes

2021/2022

Uploaded on 09/12/2022

ekaashaah
ekaashaah 🇺🇸

4.4

(40)

274 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
What is Hashing?
A hash is an into mapping of some input
(number, string) into a usually small and
usually integer number
The input is the hash key
The mapping is the hash function
The output is the hash value
The hash value is frequently used to index
(hash index) a table (hash table)
Doing a lookup in a table by referencing its index is essentially a one
cycle operation- really, really fast
pf3
pf4
pf5

Partial preview of the text

Download What is Hashing? and more Lecture notes Data Structures and Algorithms in PDF only on Docsity!

What is Hashing?

A hash is an into mapping of some input (number, string) into a usually small and usually integer number

  • The input is the hash key
  • The mapping is the hash function
  • The output is the hash value
  • The hash value is frequently used to index ( hash index) a table ( hash table) - Doing a lookup in a table by referencing its index is essentially a one cycle operation- really, really fast

Hash Collisions

f x f y x y BUT f x f y x y

Restated, necessarily f (^) onto is into. If it were, but neither necessarily 1 - 1 and onto , there would be no 1 - 1 nor even such thing as a collision.

f (x)= f (y) f

x y

f

z f

f (z)

Hash Function

A good hash function

  • Must map all substrings into the table (index

cannot exceed table size)

  • Spreads the collisions uniformly over the

table, avoiding concentrations of collisions

Issues with a Hash Table

  • Size of hash table
  • Choice of hashing function
  • Hash Collisions
    • Minimize the number of collisions
    • Avoid pockets of collisions the table - i.e., spread collisions evenly over
    • Have a process to handle collisions, both on storage and lookup
      • Chaining
      • Probing
  • Hash table lookup efficiency
    • Rapid generation of hash values