For problem like these on exam, what very importnt things to keep in mind to not mess…
Private research annotation
Sign in to add a private research label or note.
- User
For problem like these on exam, what very importnt things to keep in mind to not mess things yp Assume a hash set of integer keys with initial table size, m=7, and a hash function, h(k) = (3k) % m. The hash set uses double-hashing to resolve collisions with h2(k) = m - (k%m). Further assume that when the table reaches a loading factor of 0.5 and it will resize to a new size of 2m+3 before a new insertion is applied (an insertion may end with a loading factor of >= 0.5 but the next insertion will then cause the resize). For the sequence below, fill out the tables below the contents of the table just before it resizes and after the last insertion. Upon resize, the keys present will be inserted in the new table in the order they appear in the old table. Insert the following keys: 5, 22, 12, 15, 9, 6
- Assistant
- User
Insert 12: ( h(12) = (3 \cdot 12) % 7 = 36 % 7 = 1 ). Collision at index 1 (key 5 is there). Use ( h_2(12) ): ( h_2(12) = 7 - (12 % 7) = 7 - 5 = 2 ). Next position: ( (1 + 2) % 7 = 3 ). Collision at index 3 (key 22 is there). Next position: ( (3 + 2) % 7 = 5 ). Index 5 is empty, so insert 12 at index 5. Index 0 1 2 3 4 5 6 Key 5 22 12 Load factor: ( 3/7 ). No resizing required. explains more how did you get (3+2)
- Assistant