Professional Documents
Culture Documents
Engineering
SEC5213: Data Structures and Algorithm
Level: 5
Credit Value: 20
1
Lecturer: Ms. Sathananthy 06/04/2022
Learning Outcomes 01,03,04
• Understand the fundamentals of variety of data structures
• Evaluate algorithms and data structures in terms of time complexity
• Apply algorithms and data structures to solve programming problems.
2 06/04/2022
Outline
Hashing
Open addressing
Separate chaining
Hash functions
Hashing Efficiency
7
Hash Table
Hash Table is a data structure which stores data in an associative manner. In a hash
table, data is stored in an array format, where each data value has its own unique index
value. Access of data becomes very fast if we know the index of the desired data.
Thus, it becomes a data structure in which insertion and search operations are very fast
irrespective of the size of the data. Hash Table uses an array as a storage medium and
uses hash technique to generate an index where an element is to be inserted or is to be
located from.
4 06/04/2022
Hash Table
5 06/04/2022
Hashing Function
A function which employs some algorithm to computes the key K for all the data
The same key K can be used to map data to a hash table and all the operations like
as hash values, hash codes, hash sums, or hashes.
6 06/04/2022
Hashing
Hashing is a technique to convert a range of key values into a range of indexes of an array.
We're going to use modulo operator to get a range of key values. Consider an example of hash
table of size 20, and the following items are to be stored. Item are in the (key,value) format.
7 06/04/2022
Hashing
i. (1,20)
ii. (2,70)
iii. (42,80)
iv. (4,25)
v. (12,44)
vi. (14,32)
vii. (17,11)
viii. (13,78)
ix. (37,98)
8 06/04/2022
Hashing
Sr.No. Key Hash Array Index
1 1 1 % 20 = 1 1
2 2 2 % 20 = 2 2
3 42 42 % 20 = 2 2
4 4 4 % 20 = 4 4
5 12 12 % 20 = 12 12
6 14 14 % 20 = 14 14
7 17 17 % 20 = 17 17
8 13 13 % 20 = 13 13
9 37 37 % 20 = 17 17
9 06/04/2022
Hash Collision
linked-list.
11 06/04/2022
Hash collision resolution techniques
13 06/04/2022
A COMPARATIVE ANALYSIS OF CLOSED HASHING VS OPEN HASHING
Open Addressing Closed Addressing
15 06/04/2022
Complexity Measures : Hashing
Time Complexity
θ(1 )
Search O(n)
θ(1)
Insert O(n)
θ(1 )
Delete O(n)
16 06/04/2022
Implementation
17 06/04/2022
END
18 06/04/2022