Question: Q 3 Hash Functions Galore 2 Points Question 3 . 1 Q 3 . 1 1 Point Grading comment: Suppose we have a Dog class

Q3 Hash Functions Galore
2 Points
Question 3.1
Q3.11 Point
Grading comment:
Suppose we have a Dog class where each Dog has a name and a weight. Suppose we are trying to create the hashCode for our Dog class. Which of the two hashCodes below would guarantee to result in the two equivalent Dog objects, d1 and d2, being hashed to the same bucket in our hash table?
Dog d1= new Dog("Zeus",5);
Dog d2= new Dog("Zeus",5);
public int hashCode1(){
return (int)(Math.random()*20)+1;
}
public int hashCode2(){
return (int)this.name.length();
}
Choice 1 of 2:hashCode1()
Choice 2 of 2:hashCode2()

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 Databases Questions!