Hashing

Q.1: What are the problems encountered in hashing?

Answer:

Problems like collision, bucket overflow, bucket skew, insufficient buckets are encounterd. For each problem, we have a separate solution like collision resolution technique and dynamic hashing.

Q.2: Why hashing is more efficient than indexing?

Answer:

Efficiency of hashing rise from the fact that in hashing, we can get direct access to the exact location of the data record in the database. This is possible because of the hash function, hence it must be written by keeping certain factors in mind. In some cases, its also possible to fetch or add data in constant time. However, hashing is not suitable for finding all values in a given range as there isn’t a specific order of records.

Q.3: What is the main difference between indexing and hashing?

Answer:

Indexing uses B-tree like data structure for ordered and range queries and stores data in and ordered fashion providing logarithmic time in most operations. Hashing may provide constant time access on performing any operation but it can have collisions.

Q.4: In what other areas in computer science is hashing used?

Answer:

Hashing is a widely used technique for time and space optimization and in the context of cyber security it is also used to hash passwords (convert them to encrypted format), data verification and data integrity etc.

Q.5: What are the disadvantages of hashing?

Answer:

Following are 2 major disadvantages of hashing:

1. Lack of Range Queries: Hashing is not suitable for ordered data and fetchin a bulk amount of data in a given range, because data stored in buckets is not in an ordered format and hash function will have to be executed a number of times to fetch a long list of data, generating an overhead.

2. Sensistivity to the hash function: The hash function that’s written by the programmer must be developed by keeping in mind certain factors to ensure better performance, if it fails, every operation will consume more time to be executed.



Hashing in DBMS

Hashing in DBMS is a technique to quickly locate a data record in a database irrespective of the size of the database. For larger databases containing thousands and millions of records, the indexing data structure technique becomes very inefficient because searching a specific record through indexing will consume more time. This doesn’t align with the goals of DBMS, especially when performance and date retrieval time are minimized. So, to counter this problem hashing technique is used. In this article, we will learn about various hashing techniques.

Similar Reads

What is Hashing?

The hashing technique utilizes an auxiliary hash table to store the data records using a hash function. There are 2 key components in hashing:...

Hash Function

A hash function is a mathematical algorithm that computes the index or the location where the current data record is to be stored in the hash table so that it can be accessed efficiently later. This hash function is the most crucial component that determines the speed of fetching data....

Types of Hashing in DBMS

There are two primary hashing techniques in DBMS....

1. Static Hashing

In static hashing, the hash function always generates the same bucket’s address. For example, if we have a data record for employee_id = 107, the hash function is mod-5 which is – H(x) % 5, where x = id. Then the operation will take place like this:...

2. Dynamic Hashing

Dynamic hashing is also known as extendible hashing, used to handle database that frequently changes data sets. This method offers us a way to add and remove data buckets on demand dynamically. This way as the number of data records varies, the buckets will also grow and shrink in size periodically whenever a change is made....

FAQs on Hashing

Q.1: What are the problems encountered in hashing?...