hamburger

In which of the following hash functions, do consecutive keys map to consecutive hash values?

By BYJU'S Exam Prep

Updated on: September 25th, 2023

  1. Division method
  2. Multiplication method
  3. Folding method
  4. Mid-square method

In the division method, consecutive keys map to consecutive hash values. The hash table maps consecutive keys to successive hash values, making the division approach disadvantageous. As a result, efficiency is poor.

keys Map to Consecutive Hash Values

This is the simplest and most straightforward way to create a hash value. The value k is divided by M, and the resulting residual is used by the hash function.

Formula – h(K) = k mod M

Here,

The hash table’s size is M, and the key value is k. The fact that M is a prime number is ideal since it can ensure that the keys are distributed more evenly. The division’s remaining part is necessary for the hash function to work.

Advantages of Consecutive Hash Values:

  1. For any value of M, this approach works rather well.
  2. The division method just needs to do one division operation, hence it is very quick.

As a result, the Division approach is the appropriate response.

Mid-square method:

The address is chosen from the middle of the result after the key is squared.

Folding technique: The key is split into pieces whose dimensions correspond to those of the needed address. The address is then obtained by adding the pieces.

Method of multiplication: An irrational number multiplied by a hash function that uses the first p bits of the key.

Summary:

In which of the following hash functions, do consecutive keys map to consecutive hash values? (a) Division method (b) Multiplication method (c) Folding method (d) Mid-square method

Consecutive keys in the division method correspond to consecutive hash values. The division method is flawed because the hash table translates sequential keys to sequential hash values. Consequently, efficiency is low.

Our Apps Playstore
POPULAR EXAMS
SSC and Bank
Other Exams
GradeStack Learning Pvt. Ltd.Windsor IT Park, Tower - A, 2nd Floor, Sector 125, Noida, Uttar Pradesh 201303 help@byjusexamprep.com
Home Practice Test Series Premium