When we retrieve hash map values, we also need to be aware of the fact that two keys could point to the same array index.



In our .retrieve() method, after finding the array index, we want to check to make sure that the index corresponds to the key we’re looking for.

Save the array value at our compressed hash code into possible_return_value.


Instead of just returning the array’s contents at that index, check if possible_return_value is None. If so, return None.


If possible_return_value is not None, check if the first element in possible_return_value (index 0) is the same as key.

If so, return possible_return_value[1], the value.


If our current array value doesn’t contain the key we’re getting, we’ll need to use open addressing to find the next place where the key will be. We’ll be doing that soon!

Sign up to start coding

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?