Using the division method [h(k) = k mod m], at which positions are the key…

2021

Using the division method [h(k) = k mod m], at which positions are the key values 177 and 197 stored in a hash table when the size of the hash table is 57?

  1. A.

    6, 26

  2. B.

    7, 27

  3. C.

    26, 6

  4. D.

    27, 7

Attempted by 58 students.

Show answer & explanation

Correct answer: A

Concept

In the division method of hashing, a key k is mapped to a slot using the hash function h(k) = k mod m, where m is the table size. The remainder of k divided by m gives the home address, so every result lies in the range 0 to m − 1. The position depends only on the remainder, not on the quotient.

Application

Here m = 57. Compute the remainder of each key on division by 57:

  1. 177 = 57 × 3 + 6, so 177 mod 57 = 6. Key 177 goes to address 6.

  2. 197 = 57 × 3 + 26, so 197 mod 57 = 26. Key 197 goes to address 26.

Taking the keys in the stated order (177 first, then 197), the addresses are 6 and 26.

Cross-check

Both addresses satisfy 0 ≤ address ≤ 56, the valid index range for a table of size 57. Re-multiplying confirms the remainders: 57 × 3 + 6 = 177 and 57 × 3 + 26 = 197. So the keys 177 and 197 hash to 6 and 26.

Explore the full course: Up Lt Grade Assistant Teacher 2025