Question: Question 1: Find map.size() Question 2: Find map.get(new Husky(jeter)) Question 3: Find map.get(new Husky(jeterjeter)) Question 4: Which map values are stored in the bucket at

 Question 1: Find map.size() Question 2: Find map.get(new Husky("jeter")) Question 3:

Question 1: Find map.size()

Question 2: Find map.get(new Husky("jeter"))

Question 3: Find map.get(new Husky("jeterjeter"))

Question 4: Which map values are stored in the bucket at index 1?

Question 5: Which map values are stored in the bucket at index 2?

For this problem, assume HashMap is implemented as a separate chaining hash table with 4 buckets indexed 0 through 3. The hash table never resizes. public class Husky { public String name; public boolean equals(Object o) { Husky other = (Husky) o; return this.name.equals(other.name); } public int hashCode () { return this.name. length(); } } Suppose we run this client code. Answer the following questions after running this code. HashMap map = new HashMap(); Husky a = new Husky ("jeter"); Husky b = new Husky ("diana"); map.put(a, 1); map.put(b, 2); a.name += a.name; map.put(a, 3); map.put(b, 4); b.name += b.name; map.put(b, 5); Recall that get returns null if the key is not in the map, and that buckets are zero-indexed

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!