educative.io

How to get n * m size?

I’m so confused here. According to wikipedia, the idea of hashing is to distribute the entries (key/value pairs) across an array of buckets . In this case means, the array size is the number of buckets.

But in our website:
In the Bucket strategy, we chain different arrays together to store elements, where each array is called Bucket . The size of the array is set as:

n*m

Here, n is the number of keys it can hold, and m is the number of slots each bucket contains. Each slot holds one value or data item.

(if we count a bucket an array, then n is the number of buckets. then n*m = the number of buckets * the slots of each bucket). I don’t know why n is the number of keys. it doesn’t make any sense.

Hi Franklin,

This is Arqam from Educative. We are really happy to hear from you.

Basically n*m is the size of Hash Table, where n is the number of keys it can hold, and m is the number of slots each bucket contains.

In response to your question, our team has fixed this mistake and updated the illustrations as well for your better understandings.

Our team would love to hear more feedbacks from you!

Thanks and Regards,

Arqam Rehan | Developer Advocate

Thank you for the reply! I’m still confused. why n is the number of keys it can hold? let’s say we have 10 buckets and each bucket has 5 slots and each slot stores one key value pair. The hash table size should be 10 * 5 = 50. In this case, 10 is n and 5 is m. n*m is the number of key it holds instead of n. Am i missing anything?

1 Like