In a university system the last three digits of student ID number shows which de
ID: 3905049 • Letter: I
Question
In a university system the last three digits of student ID number shows which department the
student is enrolled in. For instance, the last three digits are 001 if the student is enrolled in com-
puting science, 101 if in engineering, and so on. Consider a hash index on students le with the
student ID number as search key using the hash function
h(StudentID) =StudentID mod1000 (e.g. h(327501)= 501 and h(320555)= 555
(a) Is this indexing approach efficient? Explain your justication.
(b) Suggest a solution to improve the performance
Explanation / Answer
Yes it is an efficient solution as mod 1000 will always yield the last 3 digits
to know the departement from the student id.There is no collision possible till the
last 3 digits are different. One small issue is the department IDs as 001 or 005
as in that case 345001 the mod operation will give 1 and not 001. So one improvement will be to append leading zeros if mod operation gives less than 100 or less than 10.
If it is less than hundred we should add one leading 0 to make it three digit and
if it is less than 10 , then we need to append two zeros to make it a 3 digit entity.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.