3 Feb 2020

  • February 03, 2020
  • Amitraj
Dynamic Hashing

-> The dynamic hashing method is used to overcome the problems of static hashing like bucket overflow.

-> In this method, data buckets grow or shrink as the records increases or decreases. This method is also known as Extendable hashing method.

-> This method makes hashing dynamic, i.e., it allows insertion or deletion without resulting in poor performance.




How to search a key

1. First, calculate the hash address of the key.

2. Check how many bits are used in the directory, and these bits are called as i.

3. Take the least significant i bits of the hash address. This gives an index of the directory.

4. Now using the index, go to the directory and find bucket address where the record might be.




How to insert a new record

1. Firstly, you have to follow the same procedure for retrieval, ending up in some bucket.

2. If there is still space in that bucket, then place the record in it.

3. If the bucket is full, then we will split the bucket and redistribute the records.



For example:
Consider the following grouping of keys into buckets, depending on the prefix of their hash address:





The last two bits of 2 and 4 are 00. So it will go into bucket B0. The last two bits of 5 and 6 are 01, so it will go into bucket B1. The last two bits of 1 and 3 are 10, so it will go into bucket B2. The last two bits of 7 are 11, so it will go into B3.







Hashing is not favorable when the data is organized in some ordering and the queries require a range of data. When data is discrete and random, hash performs the best.

-> Hashing algorithms have high complexity than indexing. All hash operations are done in constant time.





Advantages Of  Dynamic Hashing

1. In this method, memory is well utilized as it grows and shrinks with the data. There will not be any unused memory lying.

2. This method is good for the dynamic database where data grows and shrinks frequently.




Disadvantages Of  Dynamic Hashing


1. In this case, the bucket overflow situation will also occur. But it might take little time to reach this situation than static hashing.


Translate

Popular Posts