1 A certain university assigns each of its students student
1. A certain university assigns each of its students student numbers the rst time they register for any course. These numbers are sequential integers that started at 0 many years ago and are now in the millions. Suppose we have a class of one hundred rst year students and we want to assign them hash codes based on their student numbers. Does it make more sense to use the rst two digits or the last two digits of their student number? Justify your answer. • 2. Suppose you have an object made up of two w-bit integers, x and y. Show why xy does not make a good hash code for your object. Give an example of a large set of objects that would all have hash code 0.
Solution
No, it does not make sense to assign hash codes based on first 2 or last 2 digits of their student numbers. Because 2 students in the same class can have student numbers like: (198 and 298) or (192 and 199). In this case, we won\'t be able to distinguish between them.
Suppose the integers are 1111 and 0000. On applying xor, the hash would be 1111
Suppose the integers are 1010 and 0101. On applying xor, the hash would be 1111, which is the same as previous case
