Questions tagged [load-factor]

32 questions
277
votes
9 answers

What is the significance of load factor in HashMap?

HashMap has two important properties: size and load factor. I went through the Java documentation and it says 0.75f is the initial load factor. But I can't find the actual use of it. Can someone describe what are the different scenarios where we…
Priyank Doshi
  • 12,895
  • 18
  • 59
  • 82
8
votes
4 answers

Hashmap loadfactor - based on number of buckets occupied or number of entries in all buckets?

I was trying to understand the that does the rehashing of hashmap takes place while exceeding the number of buckets occupied or the total number of entries in all buckets. Means, we know that if 12 out of 16 (One entry in each bucket) of buckets are…
7
votes
2 answers

What happens if the load factor of a HashMap is greater than 1?

Default value of hashmap's load factor os 0.75f i.e it will re-hash the hash map once the 75% of capacity of hasmap is filled. What if I set the value of load factor greater than 1 for example lets say 2 (super(capacity+1, 2.0f, true);) How it will…
Samar
  • 93
  • 1
  • 4
7
votes
1 answer

Hashmap Capacity not increased even on reaching threshold

Java doc says - When the number of entries in the hash table exceeds the product of the load factor and the current capacity, the hash table is rehashed In below program - HashMap map = new HashMap(); int i =…
anmolmore
  • 161
  • 11
4
votes
1 answer

load factor in separate chaining?

Why is it recommended to have a load factor of 1.0 in separate chaining? I've seen plenty of people saying that it is recommended, but not given a clear explanation of why. With open addressing, I know the load factor should be between 0.5 and 0.7…
JozzWhers
  • 81
  • 1
  • 4
4
votes
4 answers

Does it make sense to resize an Hash Table down? And When?

My Hash Table implementation has a function to resize the table when the load reaches about 70%. My Hash Table is implemented with separate chaining for collisions. Does it make sense that I should resize the hash table down at any point or should I…
rfgamaral
  • 16,546
  • 57
  • 163
  • 275
3
votes
1 answer

What is the internal load factor of a sets in Python

I am trying to find out what the internal load factor is for the Python sets. For dictionary which uses a hash table with a load factor of 0.66 (2/3) is. The number of buckets start at 8 and when the 6th key is inserted the number of buckets…
3
votes
2 answers

Why load factor of hashmap in redis is as large as 5

In algorithm classes and authorized books, load-factor is smaller than 1 as it is with Java the default is 0.75. But in redis source code, the load factor is 5. 54 /* Using dictEnableResize() / dictDisableResize() we make possible to 55 *…
maki
  • 477
  • 2
  • 12
3
votes
3 answers

how to change the hashmap load factor

We know that hashmap has default load factor 0.75, and if I want to change it how to do that. Is there any method so that we can set and use the load factory. I have 100k records and I don't want to rehashing again and again, I want to change the…
shiv
  • 477
  • 5
  • 17
2
votes
1 answer

How do I properly calculate the load factor of a hash table that uses separate chaining?

I'm working with hash tables that use separate chaining as a collision resolution technique. I do know that the general formula is N/table_length, where N is the number of items currently in the table. I'm a bit confused by the denominator. Would it…
Adam G
  • 145
  • 1
  • 1
  • 9
2
votes
1 answer

Load factor in HashMap with linkedList

For load factor, I know it's the total number of elements divided by the space available. For the picture below, at index 2 for example, does it count as 1 spot or 6?
user6451375
2
votes
2 answers

hash table about the load factor

I'm studying about hash table for algorithm class and I became confused with the load factor. Why is the load factor, n/m, significant with 'n' being the number of elements and 'm' being the number of table slots? Also, why does this load factor…
Jason J.Y. Kim
  • 183
  • 2
  • 12
2
votes
1 answer

Load factor of hash tables with tombstones

So the question came up about whether tombstones should be included when calculating the load factor of a hash table. I thought that, given that the load factor is used to determine when to expand capacity, tombstones should not be included. An…
Pluckerpluck
  • 731
  • 6
  • 21
2
votes
3 answers

When to trash hashmap contents to avoid performance degradation?

I'm woking on Java with a large (millions) hashmap that is actually built with a capacity of 10.000.000 and a load factor of .75 and it's used to cache some values since cached values become useless with time (not accessed anymore) but I can't…
Jack
  • 131,802
  • 30
  • 241
  • 343
1
vote
0 answers

Resizing hash table using chaining method

I need to implement a program, which will insert numbers from input to hash table. I want to use chaining method to avoid collisions. The program must have a function to resize hash table. My question is, how to count load factor, and when the hash…
A.Cabb
  • 65
  • 6
1
2 3