0% found this document useful (0 votes)
54 views14 pages

Hashing

Uploaded by

bhavanavuppu1715
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)
54 views14 pages

Hashing

Uploaded by

bhavanavuppu1715
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
You are on page 1/ 14

EXTENDIBLE

HASHING
DEFINATION:
It is a Dynamic Hashing Method where in directories and buckets are

used to hash data. It is an aggressively flexible method in which the hash

function also experiences the dynamic changes.

Directories: The directories store addresses of the buckets in pointers. An id is


assigned to each directory which may change each time when Directory
Expansion takes place.

Buckets: The buckets to are used hash the actual data.


• Global Depth: It is associated with the Directories. They denote the
number of bits which are used by the hash function to categorize the
keys.
Global Depth = Number of bits in directory id.

• Local Depth: It is the same as that of Global Depth except for the fact
that Local Depth is associated with the buckets and not the directories.
Local depth in accordance with the global depth is used to decide the
action that to be performed in case an overflow occurs. Local Depth is
always less than or equal to the Global Depth.

• Bucket Splitting: When the number of elements in a bucket exceeds a


particular size, then the bucket is split into two parts.

• Directory Expansion: Directory Expansion Takes place when a bucket


overflows. Directory Expansion is performed when the local depth of
the overflowing bucket is equal to the global depth
STRUCTURE OF EXTENDIBLE HASHING
BASIC WORKING PRINCIPLE OF EXTENDIBLE HASHING

Hash function f(h)


Returns the
Directory
name/location

Directory
Points to a Bucket
Data
traverse
s
to the

Bucket
bucket
Data hashed/stored here
• Step 1 - Analyze Data Elements: Data elements may exist in
various forms eg. Integer, String, Float, etc.. Currently, let us
consider data elements of type integer.
eg: 49.

• Step 2 - Convert into binary format: Convert the data


element in Binary form. For string elements, consider the
ASCII equivalent integer of the starting character and then
convert the integer into binary form. Since we have 49 as our
data element, its binary form is 110001.

• Step 3 - Check Global Depth of the directory. Suppose the


global depth of the Hash- directory is 3.
• Step 4 - Identify the Directory: Consider the 'Global-Depth'
number of LSBs in the binary number and match it to the
directory id. Eg. The binary obtained is: 110001 and the global-
depth is 3. So, the hash function will return 3 LSBs of 110001
viz. 001.

• Step 5 - Navigation: Now, navigate to the bucket pointed by


the directory with directory-id 001.

• Step 6 - Insertion and Overflow Check: Insert the element and


check if the bucket overflows. If an overflow is encountered, go
to step 7 followed by Step 8, otherwise, go to step 9
• Step 7 - Tackling Over Flow Condition during Data
Insertion: Many times, while inserting data in the buckets, it
might happen that the Bucket overflows. In such cases, we
need to follow an appropriate procedure to avoid mishandling
of data. First, Check if the local depth is less than or equal to
the globaldepth. Then choose one of the cases below.
Case1: If the local depth of the overflowing Bucket is equal to
the global depth, then Directory Expansion, as well as Bucket
Split, needs to be performed. Then increment the global depth
and the local depth value by 1. And, assign appropriate pointers.
Directory expansion will double the number of directories
present in the hash structure.

• Case2: In case the local depth is less than the global depth,
then only Bucket Split takes place. Then increment only the local
depth value by 1. And, assign appropriate pointers.
Overflow occurs

Local depth>global Local depth=global


depth depth

Perform bucket
Perform bucket
split &directory
split
expansion
• Step 8 - Rehashing of Split Bucket Elements: The Elements
present in the overflowing bucket that is split are rehashed w.r.t
the new global depth of the directory.

• Step 9 - The element is successfully hashed


Advantages:
1.Data retrieval is less expensive (in terms of
computing).

2. No problem of Data-loss since the storage


capacity increases dynamically.

3. With dynamic changes in hashing function,


associated old values are rehashed w.r.t the
new hash function
Limitations Of Extendible Hashing:
1. The directory size may increase significantly
if several records are hashed on the same
directory while keeping the record distribution
non-uniform.

2. Size of every bucket is fixed.

3. Memory is wasted in pointers when the


global depth and local depth difference
becomes drastic.

4. This method is complicated to code


Thank you…

You might also like