Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider a hash table of size 7 with hash function h(k) = A: mod 7. Draw the has

ID: 3821831 • Letter: C

Question

Consider a hash table of size 7 with hash function h(k) = A: mod 7. Draw the hash table after inserting in it. in the given order, the following values into the table: 14, 28, 2, 26, and 70: when linear probing is used to resolve collisions when double hashing with secondary hash function h'(k) = 5 - (k mod 5) is used to resolve collisions. Consider the following binary search tree. Insert the keys 15 and 10 (in that order) into the tree and show the resulting tree. You must use the algorithms described in class for inserting data into a binary search tree.

Explanation / Answer

a)
h(k) = k mod 7
key = 14
h(14) = 14 %7 = 0 ( 14 will go to location 0)
key =28
h(28) = 28 % 7 = 0 (Collision so with linear probing 28 will go to next free loc i:e 1)
key = 2
h(2) = 2% 7 = 2 (2 will go to slot 2)
key =26
h(26) = 26 % 7 = 5 (26 will go to slot 5)
key = 70
h(70) = 70%7 = 0 (Collision so 70 will goto next free slot which is 3)
14
28
2
70
26

b) h'(k) = 5- (kmod5)
h(k) = k mod 7
key = 14
h(14) = 14 %7 = 0 (14 will go to location 0)
key =28
h(28) = 28 % 7 = 0 (Collision )
h'(28) = 5-(28%5) = 2 (2 positions from 0 i:e 2)
key = 2
h(2) = 2% 7 = 2 (collision)
h'(2) = 5-(2%5) = 3 (3 positions from 2 i:e 5)
key =26
h(26) = 26 % 7 = 5 (collision)
h'(26) = 5-(26 % 5) = 4 (4 positions from 5 i:e 2,6,)
key = 70
h(70) = 70%7 = 0 (Collision )
h'(70) = 5-(70 % 5) = 5 (5 positions from 0 i:e 5,3)
14
28
70
2
26

As per Chegg policy,we can provide only one solution at a time. I would request you to repost second question. Don't forget to rate my answer. Good Luck!

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote