You are given a hash table which uses separate chaining. The
table has a size of 10.
The hash function being used is h(x) = x.
You insert 6, 13, and 201 into the hash table. If you then insert(3) into the hash table, it will be put at which index?
You insert 9, 19, and 29 into the hash table. What is the size of the bucket at index 9?
Ans).
Hash function is h(x)= x and table size is 10.
when we insert 6, it'll ho at 6%10 = 6 index.
13 goes at 13%10=3 index
201 goes at 201%10=1 index.
Now when we insert 3, it'll go to 3%10=3 index.
Since 13 is already there, and are using chaining technique, we'll append 3 at the linked list at index 3.
so now, index 3 consists of a list containing 13 and 3.
when we put 9,19 and 29, all of them have same hash value and thus index which is 9. So all three will go to the bucket/list at index 9.
Therefore at index 9, bucket size is three.
Hope it helped! Feel free to ask any doubt in comments. Don't forget to upvote if it helped :).
Get Answers For Free
Most questions answered within 1 hours.