Static Hashing vs Dynamic Hashing

Introduction to Hashing

Data structures often contain a lot of data that is difficult to search. Hashing is an efficient solution that can be used to map these large datasets into much smaller tables using a unique hash function. This helps you access data quickly and minimizes the effort that would be required to search through each index value and level to get the required block of data.

Hashing is a computational technique in which a specialized set of functions converts variable-length information into a fixed-length shorter output, commonly known as a "hash code", "key", or simply "hash". goes. The data to which the hashing process is applied is usually referred to as a "data bucket".

Hashing is often used for various purposes such as verifying passwords, associating file names with file paths in the OS, graphics processing, and playing board games such as chess and tic-tac-toe.

In this article, you will learn the difference between two important hashing methods – static hashing and dynamic hashing.

What is static hashing?

This hashing method allows individuals to access a specific set of data. This means that the content in the directory does not fluctuate, it is "stable" or permanent. Thanks to this hashing method, the number of data segments in memory remains unchanged.

Static Hash Operations

  • Insert - When a data point is added to a static hashing system, the hash function (h) is used to determine the bucket address "h(k)" for the lookup key (k) where the record is stored. Is.
  • Lookup - When trying to access a record, you can use the same hash function to get the location of the bucket containing the data.
  • Delete - Find the associated address of a specific entry and delete that single entry or group of entries stored in memory that match the same address.
  • Updates. You can update an entry after it has been identified using a hash function.

Advantages of static hashing

  • Provides best results when working with databases of limited size.
  • You can use the primary key value as a hash key.

Disadvantages of static hashing

  • It is not scalable and unable to work effectively with large databases.
  • When the amount of data exceeds the available memory, a recycle bin overflow problem occurs.

This serious bucket overflow problem can be solved in two ways:

  • Overflow Chain − When all buckets are full, a new bucket is created to hold the same hash result.
  • Looks linear. When the hash function produces an address that already contains data, the specified data is assigned to the next free bucket.

What is dynamic hashing?

This type of hashing allows users to find information in an ever-changing set of data. That is, data can be added or removed as needed, making it a "dynamic" approach to hashing. The size of data segments grows/shrinks based on the number of records they contain. The problem with static hashing is the potential for cart overflow. Dynamic hashing avoids this problem and is also known as extensible hashing.

dynamic hash operations

  • Insert - you can find the address of the basket. If the bucket is already full, additional buckets can be added. Furthermore, additional bits can be included in the hash value and the hash function can be recalculated. If the baskets are not full, you can add data to them.
  • Question - Determine the depth of the hash index and use the data to calculate the address of the basket.
  • Delete - Runs a query to find the data that needs to be deleted.
  • Update - Executes a query to update the data.

Benefits of dynamic hashing

  • It is effective with scalable data.
  • It has the capacity to manage large amount of memory where the size of the data is constantly changing.
  • It is able to effectively solve the problem of flow in the bucket.

Disadvantages of dynamic hashing

  • The position of data in memory depends on the size of the bucket. Therefore, with large data growth, keeping the bucket address list up to date can be a challenge.

Conclusion

When it comes to hashing, there are different ways to implement it depending on whether the dataset requires a fixed or variable length segment. When choosing a hashing method, you need to consider the size of the data being processed as well as the speed of the application.

Static Hashing vs Dynamic Hashing
Static Hashing vs Dynamic Hashing


Continue Reading:

MD5 vs CRC – Detailed Comparison

What is Cryptography? Detailed Explanation


Next Post Previous Post
No Comment
Add Comment
comment url