Now lets use our open addressing scheme in the setter for our
Now that we have a hash function that uses the number of collisions to determine the hash code, we can update where we set a key in the event of a collision.
When we notice that the key we’re trying to set is different from the key at our hash code’s address, create a new variable called
number_collisions, set that equal to
number_collisions, create a new
while loop that checks if
current_array_value != key.
In the while loop, you want to replicate our setting logic while incrementing the number of collisions.
.hash() with both the
number_collisions. Save that result into
.compressor(). Save that result into
new_array_index and save the result as
current_array_value. Check against the three possibilities:
None, save the
key, overwrite the array at that address with
[key, value]and then