0
0
Data Structures Theoryknowledge~10 mins

Hash function concept in Data Structures Theory - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to show what a hash function does to a key.

Data Structures Theory
hashed_value = hash([1])
Drag options to blanks, or click blank then click option'
Alist
Bvalue
Cindex
Dkey
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using the value instead of the key as input to the hash function.
2fill in blank
medium

Complete the code to create a hash table entry using a hash function.

Data Structures Theory
index = hash(key) [1] table_size
Drag options to blanks, or click blank then click option'
A+
B/
C%
D*
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using division (/) instead of modulo (%) causes wrong index calculation.
3fill in blank
hard

Fix the error in the hash function usage to get a valid index.

Data Structures Theory
index = hash([1]) % table_size
Drag options to blanks, or click blank then click option'
Aindex
Bkey
Ctable_size
Dvalue
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Applying hash to the value or index instead of the key.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps keys to their hash indexes.

Data Structures Theory
{key: hash(key) [1] table_size for key [2] keys}
Drag options to blanks, or click blank then click option'
A%
Bin
C*
D+
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using '*' instead of '%' or wrong loop keyword.
5fill in blank
hard

Fill all three blanks to create a hash table lookup that checks if a key's hash index matches a stored index.

Data Structures Theory
if hash([1]) [2] table_size == [3]:
Drag options to blanks, or click blank then click option'
Akey
B%
Cstored_index
Dvalue
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using value instead of key or wrong operator instead of modulo.