Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A certain university assigns each of its students student numbers the first time

ID: 3571351 • Letter: A

Question

A certain university assigns each of its students student numbers the first 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 first year students and we want to assign them hash codes based on their student numbers. Does it make more sense to use the first two digits or the last two digits of their student number? Justify your answer. Suppose you have an object made up of two omega -bit integers, x and y. Show why x y does not make a good hash code for your object. Give an example of a hirge set of objects that would all have hash code 0.

Explanation / Answer

Does it make more sense to use the first two digits or the last two digits of their student number?

It makes sense to use the last 2 digits(LSD) to assign them hash codes, instead of using the first 2 digits(MSD). The reason is, as the numbers are huge (in millions), the possibilitiy is the first 2 digits will remain the same for all the 100 sutdents, and therefore, if we use those digits for hashing, all the number will lead to the same key. Where as, if we use the last 2 digits for hash, as there are 100 number of students, the number will be from 0 to 99, which will generate a unique hash for every student.

Therefore, it makes more sense to use the last 2 digits instead of the first 2 digits.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote