2. ZimCore Hubs • Apr. 30, 2020
Introduction
• >Hash tables are fundamental data
structures that provide efficient
lookup, insertion, and deletion
operations for key-value pairs. This
report aims to provide an overview
of hash tables, discuss their key
features and operations, analyze
their strengths and weaknesses,
and highlight their various
applications.
HAsh table
3. ZimCore Hubs • Apr. 30, 2020
Overview of
Hash Tables
*Definition and Purpose: A hash table, also
known as a hash map, is a data structure
that uses a hash function to map keys to
unique indices,
*Hash Function: A hash function
transforms keys into hash values, which
are used as indices to store and retrieve
data.
*Collision Resolution: Collisions occur
when two or more keys produce the same
hash value. Collision resolution
techniques such as open addressing and
separate chaining are employed to handle
collisions.
*Load Factor and Rehashing: The load
factor represents the ratio of stored
items to the total capacity of the hash
table. Rehashing is performed to maintain a
balanced load factor and avoid excessive
collisions.
HAsh table
5. ZimCore Hubs • Apr. 30, 2020
Operations
*Insertion: The process of adding a key-
value pair to a hash table. The hash
function determines the index where the
pair is stored, and collision resolution is
applied if necessary.
*Search: The operation to retrieve the
value associated with a given key. The hash
function calculates the index, and the
search is performed within the
corresponding bucket or slot.
*Deletion: Removing a key-value pair from
the hash table. The hash function locates
the index, and the item is deleted from the
appropriate bucket, considering collision
resolution mechanisms.
HAsh table
6. ASH
TABLE
ZimCore Hubs • Apr. 30, 2020
• Insertion
the search for an empty bucket proceeds through a
predefined search sequence. The first empty bucket found is
used for the new key.
• Lookup
When looking up a key, the same search sequence is used. The
search terminates when the key is found, or an empty bucket is
found in which case the key does not exist in the table.
• Removal
buckets are typically not cleared, but instead marked as
"deleted". Such buckets, called tombstones, do not cause
lookups to terminate early, and can be reused by the insert
algorithm
7. ZimCore Hubs • Apr. 30, 2020
Performance
*Time Complexity: Hash table operations
typically achieve O(1) average-case time
complexity for insertions, searches, and
deletions. However, in the worst case,
collision resolution techniques may lead
to O(n) time complexity.
*Collision Handling: The choice of
collision resolution technique affects the
performance. Open addressing can lead to
clustering and degraded performance,
while separate chaining incurs additional
memory overhead due to linked lists or
other data structures.
*Load Factor Impact: Maintaining a low load
factor is crucial to prevent excessive
collisions and maintain optimal
performance. Rehashing is performed when
the load factor exceeds a threshold, but it
incurs additional overhead.
HAsh table
8. ZimCore Hubs • Apr. 30, 2020
Applications
Databases: Hash tables are used for
efficient indexing and retrieval of data in
database systems.
Caching: Hash tables enable fast data
lookup in caching systems, improving
performance by storing frequently
accessed items.
//Caching Data is a process that stores
multiple copies of data or files in a
temporary storage location—or cache—so
they can be accessed faster.
Cryptography: Hash functions play a
critical role in cryptographic applications,
providing data integrity and security
measures.
//a method of protecting information and
communications through the use of codes,
so that only those for whom the
information is intended can read and
process it
HAsh table
9. HASH
TABLE
A hash table is a
way of storing data
whose address is
determined based on
some key data or hash
key. The hash key is a
value that can be used
to map to a specific
table location when
used as input into a
hash function.
10. ZimCore Hubs • Apr. 30, 2020
Hash
Collision
• a collision happens when different
data inputs result in the same hash
after being processed by a hashing
mechanism.
• we should note here that
collisions are not a problem but an
intrinsic characteristic of the
hashing mechanisms.
• emerge due to hashing maps any
input (regardless of its length)
into a fixed-length code. since we
have an infinite set of available
inputs and a finite set o available
outputs, the hashing mechanisms
will eventually generate repeated
hashes.
11. ZimCore Hubs • Apr. 30, 2020
Conclusion
Hash tables are versatile data structures widely used in computer
science. They provide efficient operations for storing, retrieving, and
manipulating key-value pairs. By leveraging hash functions and collision
resolution techniques, hash tables offer fast access times and find
applications in various domains, including databases, caching, and
cryptography.Hash tables, also known as hash maps, are data structures
that provide efficient lookup, insertion, and deletion operations for key-
value pairs. They use a hash function to map keys to unique indices within
an underlying array or similar structure, allowing for constant-time
access to values.
HAsh table
Hash tables are versatile data structures widely used in computer science. They provide efficient operations for storing,
retrieving, and manipulating key-value pairs. By leveraging hash functions and collision resolution techniques, hash
tables offer fast access times and find applications in various domains, including databases, caching, and
cryptography.Hash tables, also known as hash maps, are data structures that provide efficient lookup, insertion, and
deletion operations for key-value pairs. They use a hash function to map keys to unique indices within an underlying array
or similar structure, allowing for constant-time access to values.
The key components of hash tables include the hash function, which transforms keys into hash values, and collision
resolution techniques to handle cases where multiple keys produce the same hash value. Common collision resolution
methods include open addressing (probing for alternative slots) and separate chaining (storing collided items in linked
lists or other data structures).
Hash tables offer several advantages, such as fast access times, typically achieving O(1) average-case time complexity for
operations. However, collision resolution techniques and the load factor (ratio of stored items to total capacity) can
impact performance. High load factors increase the likelihood of collisions, while different collision resolution
techniques have varying effects on performance.
Hash tables find applications in various fields. They are widely used in databases for efficient indexing and retrieval, in
caching systems for quick data lookup, and in cryptography for data integrity and security measures.
13. OPEN ADDRESSING
Open addressing, or closed hashing,
is a method of collision resolution
in hash tables. With this method a
hash collision is resolved by
probing, or searching through
alternative locations in the array
(the probe sequence) until either
the target record is found, or an
unused array slot is found, which
indicates that there is no such key
in the table.
14. The three Major
collision
resolution
strategies
LINEAR PROBING
in which the interval between probes is
fixed — often set to 1.
QUADRATIC PROBING
in which the interval between probes
increases quadratically (hence, the indices
are described by a quadratic function).
DOUBLE HASHING
in which the interval between probes is
fixed for each record but is computed
by another hash function.
bsinfotech-202a
16. bsinfotech-202a
Double Hashing
Double hashing is a computer
programming technique used in
conjunction with open
addressing in hash tables to
resolve hash collisions, by
using a secondary hash of the
key as an offset when a
collision occurs. Double
hashing with open addressing is
a classical data structure on a
table �.