<p>The reason you want number of buckets N to be greater than number of keys n, is that no algorithm (hashvalue + compression) gives a perfect even distribution of keys though the buckets. So when n starts approaching N, the odds of collisions become higher. Which means you will have longer linked lists in certain buckets. Thus increasing the time to find that key.</p>

CC BY-SA 3.0
2015-08-23T18:19:26.353Z
Can the down voter tell me the reason?
developer747
CC BY-SA 3.0
2015-08-23T16:41:10.753Z
2015-08-23T16:41:10.753Z
developer747
<p>From what I read, the load factor of a hashtable is defined as n/N where n=number of items N=Number of buckets in the hash table</p>

<p>Its recommended you increase the size of your hashtable when load factor is 0.75</p>

<p>Now my question is this</p>

<p>If I have 75 items in my list and the size of the hashtable is 100, is it not possible that multiple items are in the same bucket? Which means I could also be using just 40 buckets. So why not resize when number of buckets used reaches close to 100 instead of looking at number of items?</p>

<hash-function>
Load factor of a hashtable: Why not resize based on number of actual buckets used?
Foo
# Load factor of a hashtable: Why not resize based on number of actual buckets used?

(Asked by: username_0 on 2015-08-23)

From what I read, the load factor of a hashtable is defined as n/N where n=number of items N=Number of buckets in the hash table

Its recommended you increase the size of your hashtable when load factor is 0.75

Now my question is this

If I have 75 items in my list and the size of the hashtable is 100, is it not possible that multiple items are in the same bucket? Which means I could also be using just 40 buckets. So why not resize when number of buckets used reaches close to 100 instead of looking at number of items?

**Tags:** hash-function

---

## 1 answers

### Answer by username_1 on 2015-08-23. Score: 0 | Accepted answer

The reason you want number of buckets N to be greater than number of keys n, is that no algorithm (hashvalue + compression) gives a perfect even distribution of keys though the buckets. So when n starts approaching N, the odds of collisions become higher. Which means you will have longer linked lists in certain buckets. Thus increasing the time to find that key.

> **Comments:**
> **username_1**: Can the down voter tell me the reason?  

---

