what is the load factor 0.75 mean?

2019-05-07 04:20发布

I saw a hash is implemented with load factor of 0.75. What does it mean?

4条回答
Root(大扎)
2楼-- · 2019-05-07 04:49

Load factor refers to how many hash buckets are full. .75 means 75% or 3 in 4. It isn't clear if that means the hash actually was 75% full or if the hash resizes at 75%. You'll need to provide a bit more context.

查看更多
The star\"
3楼-- · 2019-05-07 04:58

it means that the capacity will be doubled once the collection has enough elements to fit 3/4 of the capacity. Ex: you have a hashmap with size 32. when you put in 24 elements in that hashmap, it will automatically create a new hashmap, of size 64, re-hash the 24 elements and put them in the collection.

The details might depend on the implementation and language, but I think the idea should be clear enough...

查看更多
The star\"
4楼-- · 2019-05-07 05:06

It means that the hash space (the range of the hash function) has 33% more elements than the hash table is intended to contain. Thus, the table should be no more than 75% full.

查看更多
登录 后发表回答