List multiplies when its full, but hashmap/hashtable multiplies when it reaches loadfactor, so why can’t hashmap wait for resizing till its full, is it parting of underlying hasing algorithm??
List multiplies when its full, but hashmap/hashtable multiplies when it reaches loadfactor, so why
Share
There’s a big difference between an array-list and a hash-map: the former stores each entry into discrete slots, while the latter may put more than one entry into a slot if the entries’ hashes match. That means that a hash-map may start to slow down long before every slot is taken and indeed, it’s quite unlikely that you’d fill every slot once and once only before having to double-up in a slot.
If you’ve got a fixed set of things that can be hashed, it is possible to create a hash and from it a hash-map that will store just that fixed set of things in an efficient manner: the result is called a perfect hash.