Exam-style question
Try this first
Describe how a simple hash table could be used to map student identification numbers to student names. Include the role of the key, the value, the hash function and collisions.
Model answer
What a good answer should say
- The student identification number can be used as the key and the student's name can be used as the value.
- A simple hash function, such as the identification number modulo the table size, calculates a position for the key.
- The name is then associated with that position.
- If two different identification numbers produce the same hash, a collision has occurred.
Explanation
Why this works
This answer explains the mapping between keys and values, applies a simple hashing process and accurately describes what happens when two keys compute the same hash.
Common mistake
No common mistake is linked to this question yet.
