0% found this document useful (0 votes)
9 views22 pages

Aspire Hashing and Sorting

Uploaded by

Aaron Abraham
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as KEY, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views22 pages

Aspire Hashing and Sorting

Uploaded by

Aaron Abraham
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as KEY, PDF, TXT or read online on Scribd
You are on page 1/ 22

HASHING IN

STRUCTURES
DATA
BY PRITHVI RAJ SAH, BIBHINNA POUDEL, ASHISH TIWARI
Usage of Hashing:

Usage of Hashing:
Blockchain Technology:
In blockchain, cryptographic hash functions are employed to link blocks securely. Each block contains
a hash of the previous block, creating an unbroken chain. This ensures the integrity and immutability of the
entire blockchain.:

Hashing:
Hash Tables:
The most common use of hashing is in hash tables. Hash tables provide a data structure that allows
efficient insertion, deletion, and retrieval of data. They are employed in various algorithms and applications
for managing collections of items.
Password Storage:
Hashing is crucial in securing user passwords. Storing hashed passwords instead of plaintext
passwords ensures that even if a security breach occurs, sensitive user information remains protected.
What is Hashing?
CONTENT:

1. Introduction
2. Collision Resolution
Techniques
3. Hash Table using Linear
Probing
4. Seperate Chaining
5. Quadratic Probing
6. Double Hashing
7. Result & Discussion
8. Conclusion
INTRODUCTION:

What is Hashing?
Hashing is the process of converting a given key into another value. A hash function is
used to generate
the new value according to a mathematical algorithm. The result of a hash function
is known as a hash
value or simply, a hash.
INTRODUCTION (CONTD.)

It is a technique or process of mapping keys, values into the hash table by using
a hash function. It is done for faster access to elements. The efficiency of
mapping depends on the efficiency of the hash function used.
COLLISION RESOLUTION TECHNIQUES

What is Collision?
Keep in mind that two keys can generate the same hash. This phenomenon is known as a collision.
Since a hash function gets us a small number for a key which is a big integer or string, there is a possibility that
two keys result in the same value. The situation where a newly inserted key maps to an already occupied slot
in the hash table is called collision and must be handled using some collision handling technique.
COLLISION RESOLUTION TECHNIQUES (CONTD.)

COLLISION
RESOLUTION
TECHNIQUES

Open Addressing
Chaining (Closed Hashing)
1. Linear Probing

(OpenHashin 2. Quadratic

g) Probing
3. Double

Hashing
LINEAR PROBING
In these schemes, each cell of a hash table stores a single key–value pair. When
the hash function causes a collision by mapping a new key to a cell of the hash table
that is already occupied by another key, linear probing searches the table for the
closest following free location and inserts the new key there.
E.g. Let us consider a simple hash function as “key mod 7” and a sequence of
keys as 50, 700, 76, 85, 92, 73, 101.
Open Chaining Separate Hashing


Open Chaining Separate Hashing


Quadratic probing

A collision resolution technique that uses formula (u=I sq.). formula to resolve Collision
technique.
Given data,
A=3,2,9,6,11,13,7,12
h(k)=2K+3
m=10
Formula given=(u+I²)
Check collision at 11.
Quadratic Probing


Double Hashing

A Collison resolution Technique where it uses double hashing method. Basically includes
double hash function.
Given data, `
A=3,2,9,6,11,13,7,12
H1(k)=2k+3
h2(k)=3k+1
mod=10
Formula given,
(u+v*I)%m
v=(h2(k)=3k+1)).
Check collision at 11.
Double Hashing


RESULT & DISCUSSION:

Hashing is most commonly used to implement hash tables. A hash table stores
key/value pairs in the form of a list where any element can be accessed using
its index.
Since there is no limit to the number of key/value pairs, we can use a hash
function to map the keys to
the size of the table; the hash value becomes the index for a given element.
A simple hashing approach would be to take the modular of the key (assuming
it’s numerical) against the table’s size:
index = key \text{ } MOD \text{ } tableSizeindex=key MOD tableSize
This will ensure that the hash is always within the limits of the table size.
CONCLUSION:

Hash tables are used to store data using a pair of keys and
values.
A hash function uses a mathematical algorithm to calculate
the hash value.
A collision occurs when the same hash value is generated for
more than one value.
Chaining solves collision by creating linked lists.
Probing solves collision by finding empty slots in the hash
table.
THANK YOU

You might also like