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
Why do collisions happen in a hash table?
Collisions happen when two different keys produce the same index from the hash function. This means both values want to be stored in the same place.
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 hash to the same index, they are stored in the list at that index.
Click to reveal answer
advanced
What properties make a good hash function?
A good hash function distributes keys evenly across the table, is fast to compute, and minimizes collisions.
Click to reveal answer
What does a hash function output in a hash table?
✗ Incorrect
The hash function outputs an index where the value is stored or retrieved.
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 pairs in a list at the same index to handle collisions.
Why should a hash function distribute keys evenly?
✗ Incorrect
Even distribution reduces collisions and makes data retrieval faster.
What is stored in a hash table?
✗ Incorrect
Hash tables store key-value pairs for fast lookup.
Explain how a hash table uses a hash function to store and retrieve data.
Think about how a key becomes a place to find the value.
You got /3 concepts.
Describe what a collision is in a hash table and one way to handle it.
Imagine two people trying to sit in the same chair.
You got /3 concepts.
