0% found this document useful (0 votes)
10 views10 pages

Hash

A hash table is a data structure that associates keys with values, enabling efficient search, insertion, and deletion operations. It uses a hash function to convert keys into indexed positions in the table, allowing for quick data access. Collision handling methods include chaining, using overflow areas, and searching neighboring slots.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views10 pages

Hash

A hash table is a data structure that associates keys with values, enabling efficient search, insertion, and deletion operations. It uses a hash function to convert keys into indexed positions in the table, allowing for quick data access. Collision handling methods include chaining, using overflow areas, and searching neighboring slots.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Hash Table

• is a data structure that associate key and value


• It is an ADT and maintain a set of items each with a key.
Used for search, delete and insert.
• calculation applied to a key which may be a very large
number or a very long string to transform it into a
relatively small indexed number that corresponds to a
position in the hash table this index number is
effectively a memory address for numeric keys.
• widely used in database indexing caching program
compilation error checking and much more
• quick searching, fast Insertion and deletion
• The hash function translates the key associated with
each record into a hash code which is used to index the
hash table
Properties
 fast to compute
 uniform distribution of data
 O(1) (Order of 1)
 calculation applied to a key to transform it into an
address
 for numeric keys, divide the key by the number of
available addresses,n, and take the remainder

address = key Mod n


A hash table is made up of two parts: an array (the actual table
where the data to be searched is stored ) and a hash function
(mapping function).
e.g.
Key: John
Value: Phone #

0 1 2 3 4

Hash(Key)  Index
Hash(Ali) 3
Hash(Dan)  2
Hash (Abhi)  3
Handle collisions

# chaining: create a linked list for collisions with start


[Link] the hashed address
#using overflow areas: all collisions are stored in a
separate overflow area, known as 'closed hashing'
# using neighbouring slots: perform a linear search from
the hashed address to find an empty slot, known as 'open
hashing' .
Chaining: create a linked list for collisions with start [Link] the hashed address
Chaining: create a linked list for collisions with start [Link] the hashed address
Using neighbouring slot
Key: John
Value: Phone #
0 1 2 3 4

Hash(Key)  Index
Hash(Ali) 3
Hash(Dan)  2
Hash (Abhi)  3

You might also like