Complete the code to show what a hash function does to a key.
hashed_value = hash([1])A hash function takes a key as input and returns a hashed value. This hashed value is used to find the data quickly.
Complete the code to create a hash table entry using a hash function.
index = hash(key) [1] table_sizeThe modulo operator % is used to keep the hash value within the table size, so the index fits in the table.
Fix the error in the hash function usage to get a valid index.
index = hash([1]) % table_sizeThe hash function must be applied to the key, not the value or other variables, to get a correct index.
Fill both blanks to create a dictionary comprehension that maps keys to their hash indexes.
{key: hash(key) [1] table_size for key [2] keys}The modulo operator % keeps the hash within table size. The keyword in is used to loop over keys.
Fill all three blanks to create a hash table lookup that checks if a key's hash index matches a stored index.
if hash([1]) [2] table_size == [3]:
The key is hashed and modulo applied to get the index. This index is compared to the stored index to find the correct slot.