Question:

A hash function f defined as f(key) = key mod 7, with linear probing, is used to insert the keys 37, 38, 72, 48, 98, 11, 56 into a table indexed from 0 to 6. What will be the location of key 11?

Show Hint

Use modulo operation to compute the initial index, and handle collisions with linear probing by checking subsequent indices.
Updated On: Dec 29, 2024
  • 6
  • 2
  • 4
  • 0
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is C

Solution and Explanation

Steps for insertion: 1. **Key 37:** 37 mod 7 = 2. Inserted at index 2. 2. **Key 38:** 38 mod 7 = 3. Inserted at index 3. 3. **Key 72:** 72 mod 7 = 2. Collision! Linear probing places it at the next available index, 4. 4. **Key 48:** 48 mod 7 = 6. Inserted at index 6. 5. **Key 98:** 98 mod 7 = 0. Inserted at index 0. 6. **Key 11:** 11 mod 7 = 4. Collision! Linear probing places it at the next available index, 5.
Was this answer helpful?
0
0

Top Questions on Programming and Data Structures

View More Questions