Question
In C++



raw the hash table that results from separate chaining using the follo 15 4 22 7 18 21 8 35 11 28 and the following hash function h(key)-key % 7 with a hash table size of 7. [47.1 points
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Initially the hashtable will be empty.

4 CR

Given hash function is key % 7.

1. For key 15, 15%7 = 1. So, it will be inserted at 1.

15 4 CR

2. Next 4 is inserted at 4 (since 4%7 = 4)

15 4 4 CR

3. Next element is 22. Now 22%7 = 1. But index 1 is already occupied with 15. Now separate chaining occurs. A new list will be created at the index 1 where rest of the elements with same hash value can be placed.

15 4 4

4. Next element is 7. 7%7 = 0. Hence it will be placed at index 0.

15 4 4

5. Next element is 18. 18%7 = 4. Since 4 is already occupied with element 4. Chaining occurs.

15 4 4 18 CR

6. 21 will be placed at 0 (with chaining) since 21%7 = 0.

21 15 4 4 18 CR

7. 8 will be placed at index 1 (appended in the list) since 8%7 = 1.

8. 35 too will be placed at index 0 since 35%7 = 0.

21 35 15 4 4 18

9. Now 11 will be appended at index 4 since 11%7 = 4.

15 4 4 18

10. 28 will be appended at index 0 since 28%7 = 0. (This is the final hashtable state)

21 35 28 15 4 4 18 11

Add a comment
Know the answer?
Add Answer to:
In C++ raw the hash table that results from separate chaining using the follo 15 4...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT