Recall & Review
beginner
What is a hash table?
A hash table is a data structure that stores key-value pairs. It uses a hash function to convert keys into an index where the value is stored, allowing fast data retrieval.
Click to reveal answer
beginner
What is the role of a hash function in a hash table?
A hash function takes a key and returns an integer index. This index tells where to store or find the value in the hash table.
Click to reveal answer
intermediate
What is a collision in a hash table?
A collision happens when two different keys produce the same index from the hash function. The hash table must handle collisions to store both values correctly.
Click to reveal answer
intermediate
Name one common method to handle collisions in hash tables.
One common method is chaining, where each index stores a list of key-value pairs. If multiple keys map to the same index, they are stored in the list at that index.
Click to reveal answer
intermediate
Why should a hash function distribute keys uniformly?
Uniform distribution helps avoid many keys clustering at the same index, which keeps data retrieval fast and efficient.
Click to reveal answer
What does a hash function do in a hash table?
✗ Incorrect
A hash function converts a key into an index to store or find the value in the hash table.
What is a collision in a hash table?
✗ Incorrect
A collision happens when two different keys produce the same index from the hash function.
Which method stores multiple key-value pairs at the same index to handle collisions?
✗ Incorrect
Chaining stores multiple key-value pairs in a list at the same index to handle collisions.
Why is uniform distribution important in a hash function?
✗ Incorrect
Uniform distribution avoids many keys clustering at the same index, keeping retrieval fast.
What type of data structure is a hash table?
✗ Incorrect
A hash table stores data as key-value pairs for fast access.
Explain how a hash table uses a hash function to store and retrieve data.
Think about how a key becomes a position in the table.
You got /3 concepts.
Describe what a collision is in a hash table and one way to handle it.
Imagine two friends trying to sit on the same chair.
You got /3 concepts.