Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Text p 484 Execise 3.4.33 A bad string hash function. Consider the following hashCode() implementation for String, which was used in early versions of Java:
Text p 484 Execise 3.4.33 A bad string hash function. Consider the following hashCode() implementation
for String, which was used in early versions of Java:
public int hashCode() { int hash = 0; int skip = Math.max(1, length() / 8); for (int i = 0; i < length(); i += skip) hash = (hash * 37) + charAt(i); return hash; } |
Explain why you think the designers chose this implementation
and then
explain why you think it was abandoned in favor
of the one in the previous exercise (p.484 Ex 3.4.32)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started