Exam-style question
Try this first
What is the main purpose of a hash function in a hash table?.
- A.To calculate a location from a key
- B.To arrange values into a hierarchy
- C.To remove the oldest item first
- D.To make a stack dynamic
Model answer
What a good answer should say
- To calculate a location from a key
Explanation
Why this works
A hash function converts a key into a value that can be used to identify a location in a hash table. If two keys produce the same location, the collision must be handled by the implementation.
Common mistake
No common mistake is linked to this question yet.
