where linear probing is used to handle collisions. The hash table is initially empty and then the following sequence of keys is inserted into the hash table: . The indices where the keys and are stored are, respectively
D
Step-by-Step Solution
Key idea: This is a hash table tracing question, recognizable because it provides a specific hash function, collision resolution strategy, and a sequence of keys to insert.
Step 1: Understand the hash function and table size. The table has size 10 (indices 0 to 9). The hash function is .
Step 2: Trace the insertion of each key sequentially using linear probing.
- Insert 1: . Index 3 is empty. Place 1 at index 3.
- Insert 4: . Index 2 is empty. Place 4 at index 2.
- Insert 5: . Index 5 is empty. Place 5 at index 5.
- Insert 6: . Index 8 is empty. Place 6 at index 8.
- Insert 14: . Index 2 is occupied (by 4).
- Probe 1: . Index 3 is occupied (by 1).
- Probe 2: . Index 4 is empty. Place 14 at index 4.
- Insert 15: . Index 5 is occupied (by 5).
- Probe 1: . Index 6 is empty. Place 15 at index 6.
Step 3: Identify the final indices. Key 14 is at index 4, and key 15 is at index 6.
Answer: D