Question: C + + Code, Hash Tables int y ( x , buckets ) { int result = 0 ; while ( x ! = 0

C++ Code, Hash Tables
int y(x, buckets){
int result =0;
while ( x !=0){
// Multiply the first and last digits of x and add it to result.
result += last_digit(x)* first_digit(x)
x = remove_first_and_last_digit(x)
}
return (result mod buckets)
}
What bucket will the key 12345678 hash into, when the hash function is the y shown above and there are 100 buckets?
Which one of the following hash functions distributes the following items {Eetu,Kai,Nelli,Kaisa,Elias} most evenly, if there are 9 buckets? (Note. All of the hash functions given are actually quite bad.)
a) the first letters running number in the alphabet mod 9.
b) the length of the key mod 9.
c) the first letters running number in the alphabet multiplied by the length of the key mod 9.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!