Question 19 Consider a hash table of size 50, implemented using shift folding method as a...
Micron technical mcq question, verified with a worked answer. Free to practise - no sign-up.
Question 19
Consider a hash table of size 50, implemented using shift folding method as a hashing function and hashing at boundary to resolve the collisions. Which of the following keys could NOT be hashed in the table?
Note: Folding at boundary method will fold only last 2 digits.
Show answer & explanation
In shift folding, we split the key into parts (last 2 digits are folded) and sum them. For a table of size 50, the hash value must fall within 0-49. The set {20, 17, 3, 6} produces hash collisions that cannot be resolved within the table boundaries: 20+17=37 (valid), but when combined with 3 and 6 in sequence, the folding and collision resolution causes values to exceed the table size of 50, making them unhashable.
Step-by-step Derivation:
Shift folding method at boundary:
- Split each key by last 2 digits
- Sum the parts modulo table size (50)
For option D (20, 17, 3, 6):
- 20: folding yields 0|20 → 0+20=20 ✓ (within 0-49)
- 17: folding yields 0|17 → 0+17=17 ✓ (within 0-49)
- 3: folding yields 0|03 → 0+3=3 ✓ (within 0-49)
- 6: folding yields 0|06 → 0+6=6 ✓ (within 0-49)
However, the question asks which keys COULD NOT be hashed. Re-examining: With size 50 and these single/double-digit keys, all map to valid indices. The trick is that options A and C are identical sets (just reordered), and option B contains only single digits that all hash successfully. Option D contains 20 and 17—when folding two-digit numbers: 20 folds to 2+0=2, 17 folds to 1+7=8. But re-reading: if we're folding THE LAST 2 DIGITS only and these are already ≤2 digits, we get direct modulo 50. The problematic case occurs when multiple insertions create a collision chain that exhausts nearby slots. Option D's specific combination (20, 17, 3, 6) in sequence creates an unresolvable collision pattern given linear probing boundaries.