Grokking Java Interview Questions
0% completed
HashMap Resizing, Treeification, and Key Design
A new HashMap has 16 buckets. Suppose an online grocery store loads the stock counts of 1,000 products into one. The map doubles its array each time the entries pass three quarters of the buckets: 16, 32, 64, 128, 256, 512, 1,024, and 2,048. That is seven doublings, and each one places every entry in a new array.
The four questions below cover the rule that starts a doubling, the new position of each entry, the tree that replaces a long list in one bucket, and the design of the key class.
What are capacity and load factor, and when does a HashMap grow?
Level: Mid-level
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%