## What's hot

Hash table in data structure and algorithm
Hash table in data structure and algorithm
Aamir Sohail

Hashing
Linear search-and-binary-search
Linear search-and-binary-search
International Islamic University

Graph traversals in Data Structures
Graph traversals in Data Structures
Anandhasilambarasan D

Binary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of Algorithms
Drishti Bhalla

Chapter 12 ds
Chapter 12 ds

Hashing
Hashing
kurubameena1

sorting and its types
sorting and its types
SIVASHANKARIRAJAN

Binary search
Binary search
AparnaKumari31

Hashing algorithms and its uses
Hashing algorithms and its uses

Hashing and Hash Tables
Hashing and Hash Tables

B and B+ tree
B and B+ tree
Ashish Arun

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

Hash table
Hash table
Rajendran

Hashing
Hashing
Ghaffar Khan

linear probing
linear probing
rajshreemuthiah

Quick sort-Data Structure
Quick sort-Data Structure
Jeanie Arnoco

Binary Tree Traversal
Binary Tree Traversal
Dhrumil Panchal

Quick Sort
Quick Sort
Shweta Sahu

Data structure - Graph
Data structure - Graph

### What's hot(20)

Hash table in data structure and algorithm
Hash table in data structure and algorithm

Hashing
Hashing

Linear search-and-binary-search
Linear search-and-binary-search

Graph traversals in Data Structures
Graph traversals in Data Structures

Binary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of Algorithms

Chapter 12 ds
Chapter 12 ds

Hashing
Hashing

sorting and its types
sorting and its types

Binary search
Binary search

Hashing algorithms and its uses
Hashing algorithms and its uses

Hashing and Hash Tables
Hashing and Hash Tables

B and B+ tree
B and B+ tree

Lec 17 heap data structure
Lec 17 heap data structure

Hash table
Hash table

Hashing
Hashing

linear probing
linear probing

Quick sort-Data Structure
Quick sort-Data Structure

Binary Tree Traversal
Binary Tree Traversal

Quick Sort
Quick Sort

Data structure - Graph
Data structure - Graph

## Viewers also liked

Hashing
Hashing
debolina13

Coalesced hashing / Hash Coalescido
Coalesced hashing / Hash Coalescido

08 Hash Tables
08 Hash Tables
Andres Mendez-Vazquez

Hashing Algorithm
Hashing Algorithm
Hayi Nukman

SEO Website Analysis - example report
SEO Website Analysis - example report
Lynn Holley III

Seo analysis report template (1)
Seo analysis report template (1)
Doiphode Vishal

Hash tables
Hash tables
Chester Hartin

Html, CSS & Web Designing
Html, CSS & Web Designing
Leslie Steele

Data Structure & Algorithms | Computer Science
Data Structure & Algorithms | Computer Science
Transweb Global Inc

Design & Analysis Of Algorithm
Design & Analysis Of Algorithm
Computer Hardware & Trouble shooting

Web Development on Web Project Report
Web Development on Web Project Report
Milind Gokhale

E commerce project report
E commerce project report

Website analysis sample report
Website analysis sample report
Sukumar Jena

### Viewers also liked(13)

Hashing
Hashing

Coalesced hashing / Hash Coalescido
Coalesced hashing / Hash Coalescido

08 Hash Tables
08 Hash Tables

Hashing Algorithm
Hashing Algorithm

SEO Website Analysis - example report
SEO Website Analysis - example report

Seo analysis report template (1)
Seo analysis report template (1)

Hash tables
Hash tables

Html, CSS & Web Designing
Html, CSS & Web Designing

Data Structure & Algorithms | Computer Science
Data Structure & Algorithms | Computer Science

Design & Analysis Of Algorithm
Design & Analysis Of Algorithm

Web Development on Web Project Report
Web Development on Web Project Report

E commerce project report
E commerce project report

Website analysis sample report
Website analysis sample report

## Similar to Hashing

Hashing
Hashing And Hashing Tables
Hashing And Hashing Tables
Chinmaya M. N

Hashing techniques, Hashing function,Collision detection techniques
Hashing techniques, Hashing function,Collision detection techniques
ssuserec8a711

hashing in data strutures advanced in languae java
hashing in data strutures advanced in languae java
ishasharma835109

LECT 10, 11-DSALGO(Hashing).pdf
LECT 10, 11-DSALGO(Hashing).pdf

Hashing
Hash table
Hash table
Vu Tran

Unit viii searching and hashing
Unit viii searching and hashing
Tribhuvan University

unit-1-dsa-hashing-2022_compressed-1-converted.pptx
unit-1-dsa-hashing-2022_compressed-1-converted.pptx
BabaShaikh3

introduction to trees,graphs,hashing
introduction to trees,graphs,hashing
Akhil Prem

searching techniques.pptx
searching techniques.pptx
Dr.Shweta

Unit 8 searching and hashing
Unit 8 searching and hashing
Dabbal Singh Mahara

Presentation.pptx
Presentation.pptx
AgonySingh

11_hashtable-1.ppt. Data structure algorithm
11_hashtable-1.ppt. Data structure algorithm
farhankhan89766

cajiwol341

Hashing .pptx
Hashing .pptx
ParagAhir1

4.4 hashing
4.4 hashing
Krish_ver2

Chapter 4.pptx
Chapter 4.pptx
Tekle12

L21_Hashing.pdf
L21_Hashing.pdf

Lecture14_15_Hashing.pptx
Lecture14_15_Hashing.pptx
SLekshmiNair

### Similar to Hashing(20)

Hashing
Hashing

Hashing And Hashing Tables
Hashing And Hashing Tables

Hashing techniques, Hashing function,Collision detection techniques
Hashing techniques, Hashing function,Collision detection techniques

hashing in data strutures advanced in languae java
hashing in data strutures advanced in languae java

LECT 10, 11-DSALGO(Hashing).pdf
LECT 10, 11-DSALGO(Hashing).pdf

Hashing
Hashing

Hash table
Hash table

Unit viii searching and hashing
Unit viii searching and hashing

unit-1-dsa-hashing-2022_compressed-1-converted.pptx
unit-1-dsa-hashing-2022_compressed-1-converted.pptx

introduction to trees,graphs,hashing
introduction to trees,graphs,hashing

searching techniques.pptx
searching techniques.pptx

Unit 8 searching and hashing
Unit 8 searching and hashing

Presentation.pptx
Presentation.pptx

11_hashtable-1.ppt. Data structure algorithm
11_hashtable-1.ppt. Data structure algorithm

Hashing .pptx
Hashing .pptx

4.4 hashing
4.4 hashing

Chapter 4.pptx
Chapter 4.pptx

L21_Hashing.pdf
L21_Hashing.pdf

Lecture14_15_Hashing.pptx
Lecture14_15_Hashing.pptx

## More from Dawood Faheem Abbasi

Dawood Faheem Abbasi

TCP/IP and UDP protocols
TCP/IP and UDP protocols
Dawood Faheem Abbasi

Report writing
Report writing
Dawood Faheem Abbasi

UML constructs
UML constructs
Dawood Faheem Abbasi

Mathematical induction and divisibility rules
Mathematical induction and divisibility rules
Dawood Faheem Abbasi

Dawood Faheem Abbasi

7 cs of communication
7 cs of communication
Dawood Faheem Abbasi

Geography of pakistan
Geography of pakistan
Dawood Faheem Abbasi

FET (Field Effect Transistors)
FET (Field Effect Transistors)
Dawood Faheem Abbasi

Cyber crime.pptx
Cyber crime.pptx
Dawood Faheem Abbasi

BJT’s (bipolar junction transistor)
BJT’s (bipolar junction transistor)
Dawood Faheem Abbasi

### More from Dawood Faheem Abbasi(11)

TCP/IP and UDP protocols
TCP/IP and UDP protocols

Report writing
Report writing

UML constructs
UML constructs

Mathematical induction and divisibility rules
Mathematical induction and divisibility rules

7 cs of communication
7 cs of communication

Geography of pakistan
Geography of pakistan

FET (Field Effect Transistors)
FET (Field Effect Transistors)

Cyber crime.pptx
Cyber crime.pptx

BJT’s (bipolar junction transistor)
BJT’s (bipolar junction transistor)

Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia

DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi

How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George

How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George

The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association

বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)

BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection

South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa

World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907

How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George

The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1

A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão

ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB

Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim

Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7

Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery

Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
simonomuemu

AyyanKhan40

MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha

Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25

Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx

DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share

How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory

How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method

The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection

বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf

BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...

South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)

World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024

How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM

The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx

A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf

ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...

Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf

Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit

Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie

Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT

MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE” .

Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student

### Hashing

• 1.
• 3. UNIVERSITY OF AZAD JAMMU & KASHMIR MUZAFFARABAD DEPARTMENT OF CS&IT DATA STRUCTURE • Dawood Faheem Abbasi BSCS-III-05
• 4. OUTLINE1. Searching methods – Linear search – Binary search – Hashing • Introduction • Dictionary • Hash table • Working of hash table • Hash functions – Division method – Mid square method – Folding method • Algorithm • Characteristics of good hash function • Collision • Collision resolution – Separate chaining – Closed hashing • Applications of hashing
• 5. SEARCHING METHODS • Sequential or Linear Searching. • Binary Search. • Hashing.
• 6. SEQUENTIAL SEARCH • Searches on unordered and ordered tables in sequential manner until the desired record is not found or table end is not reached. • It is simple and good for small arrays. • Mostly used when data is not sorted. • Less efficient if array size is large. • Consumes a lot of time as compared to other techniques. • Not efficient on sorted arrays.
• 7. BINARY SORT • This technique works better on sorted arrays and can be applied only on sorted arrays. • Not applied on Linked Lists. • Requires less number of comparisons than linear search. • Efficiency: O(log2n). • Logic behind the technique: Second HalfFirst Half mid=(low+high)/2 Last ValueFirst Value
• 8. EFFICIENCY: • Best – O(1) Constant time • Average – O(n/2) Here, n represents the number of elements in array • Worst – O(n) Here, n represents the number of elements in array Apply NowApply NowApply Now
• 11. INTRODUCTION Hashing is the transformation of long strings or information into a usually shorter fixed-length value or key that represents the original string or information. Hashing is used to index and retrieve items in a database because it is faster to find the item using the shorter hashed key than to find it using the original value.  It is also used in many encryption algorithms. A table of records in which a key is used for retrieval is often called a SEARCH TABLE or DICTIONARY.
• 12. DICTIONARY • A dictionary is a collection of elements • Each element has a field called key – (key, value) • Every key is usually distinct. • Typical dictionary operations are: – Insert a pair into the dictionary – Search the pair with a specified key – Delete the pair with a specified key
• 13. HASH TABLE • A hash table is a data structure that stores elements and allows insertions, lookups, and deletions to be performed in O(1) time. • A hash table is an alternative method for representing a dictionary • In a hash table, a hash function is used to map keys into positions in a table. This act is called hashing • Hash Table Operations – Search: compute f(k) and see if a pair exists – Insert: compute f(k) and place it in that position – Delete: compute f(k) and delete the pair in that position • In ideal situation, hash table search, insert or delete takes (1)
• 14. WORKING OF HASH TABLE • The table part is just an ordinary array, it is the Hash that we are interested in. • The Hash is a function that transforms a key into address or index of array(table) where the record will be stored. If the size of the table is N, then the integer will be in the range 0 to N-1. The integer is used as an index into the array. Thus, in essence, the key itself indexes the array. • If h is a hash function and k is key then h(k) is called the hash of the key and is the index at which a record with the key k should be placed. • The hash function generates this address by performing some simple arithmetic or logical operations on the key
• 15. HASH FUNCTIONS • It Is the technique of using key to determine the address of a record so that no space is wasted. • Division method or function • Mid-square method or function • Folding method or function
• 16. DIVISION METHOD • Division method computes the value of Hash as the remainder when the key is divided by a specified prime number or it can be the size of the table. • The hash function is defined as H(k)=K( mod m) Where K is the key and m is a prime number or size of the table.
• 17.
• 18. MIDSQUARE METHOD • In this method we squared the KEY and then the HASH FUNCTION is defined as: H(K)=I Where I is the value which we obtain by deleting equal digits from both sides ok K(square).
• 19. EXAMPLE • Followings are some keys k= 4012 8090 K (sqr)= 16096144 65448100 H( k)= 96 48
• 20. FOLDING METHOD • In this method we divide the key value in two parts. And then we add them. FOR EXAMPLE: K= 4012 1027 40+12=52 10+27=37 J=52 J=37 Here J is the value which we obtain by adding the KEY value.
• 21. ALGORITHM • Our goal in choosing any hashing algorithm is to spread out the record as uniformly as possible over the range of addresses available • It has three steps • Represent the key in any numerical form • Fold and add • Divide by the size of the address space and use the reminder as an address.
• 22. EXAMPLE • Pairs are: (22,a),(33,c),(3,d),(72,e),(85,f)--(key, value) pairs • Hash table is ht[0:7], m = 8 (where m is the number of positions in the hash table) • Hash function h is k % m = k % 8 • Where are the pairs stored? [0] [1] [2] [3] [4] [5] [6] [7] [0] [1] [2] [3] [4] [5] [6] [7] (72,e) (33,c) (85,f) (22,a)(3,d)
• 23. CHARACTERISTICS OF GOOD HASH FUNCTION The hash value is fully determined by the data being hashed. The hash function uses all the input data. The hash function "uniformly" distributes the data across the entire set of possible hash values. The hash function generates very different hash values for similar strings.
• 24. COLLISIONS AND THEIR RESOLUTION • A collision occurs when two different keys hash to the same value – E.g. For Table Size = 17, the keys 18 and 35 hash to the same value – 18 mod 17 = 1 and 35 mod 17 = 1 • Cannot store both data records in the same slot in array!
• 25. COLLISION RESOLUTION A method that is used to resolve the collision in Hash function is called Collision Resolution. • Two different methods for collision resolution: – Separate Chaining: Use a dictionary data structure (such as a linked list) to store multiple items that hash to the same slot – Closed Hashing (or probing): search for empty slots using a second function and store item in first empty slot that is found
• 26. SEPARATE CHAINING • Put a little dictionary at each entry – choose type as appropriate – common case is unordered linked list (chain) • Properties – performance degrades with length of chains –  can be greater than 1 3 2 1 0 6 5 4 a d e b c h(a) = h(d) h(e) = h(b)
• 27. CLOSED HASHING Problem with separate chaining: Memory consumed by pointers – What if we only allow one Key at each entry? – two objects that hash to the same spot can’t both go there – first one there gets the spot – next one must go in another spot • Properties – performance degrades with difficulty of finding right spot a c e 3 2 1 0 6 5 4 h(a) = h(d) h(e) = h(b) d b
• 28. APPLICATIONS • File management- working out where to store records • Comparing complex values • Cryptography- creating digital signatures and passwords. • Dictionaries • Security systems
• 29. THANK YOUT A K E A S M I L E , T H E Y A R E F R E E 
Current LanguageEnglish
Español
Portugues
Français
Deutsche