Consider a 13 element hash table for which f(key)=key mod 13 is used w...
To determine the location where the key 103 would be inserted in the hash table, we need to follow the steps of the linear probing collision resolution method.
1. Hash Function:
The hash function used in this case is f(key) = key mod 13. This means that the remainder of the key divided by 13 determines the index in the hash table where the key will be inserted.
2. Inserting the Keys:
Let's go step by step and insert the given keys into the hash table using linear probing:
- Inserting key 661:
Using the hash function, f(661) = 661 mod 13 = 11. Since the index 11 is empty, we can directly insert key 661 at index 11.
Hash Table:
Index: 0 1 2 3 4 5 6 7 8 9 10 11 12
Key: [ , , , , , , , , , , , 661, ]
- Inserting key 182:
Using the hash function, f(182) = 182 mod 13 = 10. Since the index 10 is empty, we can directly insert key 182 at index 10.
Hash Table:
Index: 0 1 2 3 4 5 6 7 8 9 10 11 12
Key: [ , , , , , , , , , , 182, 661, ]
- Inserting key 24:
Using the hash function, f(24) = 24 mod 13 = 11. Since the index 11 is occupied, we need to perform linear probing to find the next available index. Starting from index 11, we move to the next index 12, which is empty. Therefore, key 24 is inserted at index 12.
Hash Table:
Index: 0 1 2 3 4 5 6 7 8 9 10 11 12
Key: [ , , , , , , , , , , 182, 661, 24 ]
- Inserting key 103:
Using the hash function, f(103) = 103 mod 13 = 0. Since the index 0 is empty, we can directly insert key 103 at index 0.
Hash Table:
Index: 0 1 2 3 4 5 6 7 8 9 10 11 12
Key: [103, , , , , , , , , , 182, 661, 24 ]
Therefore, the key 103 would be inserted at index 0 in the hash table when using linear probing collision resolution. Hence, the correct answer is option 'B'.