Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Probabilistic Databases

Authors: Dan Suciu, Dan Olteanu, Christopher Re, Christoph Koch

1st Edition

3031007514, 978-3031007514

More Books

Students also viewed these Databases questions