# Balls & Bins has N Numbers with Capacity of 1000 each

I am new to this Community. Actually I am myself a Software Engineer and our company has stuck to a problem and has not come up with a solution for many days. So, I just remembered an old school Math Chapter of Probability and a King to pass 8 doors etc. I thought Mathematicians can solve this problem.

So, here is the problem, we have an increasing numbers of Email Addresses and Buckets. And each Bucket can hold 1000 Emails

Just for a side note, if it is hard to work on alphabats, we can convert each email to numbers first like a=1, b=2, c=3 ... z=26 with 0 (Zero) appended for making it unique and +s for @ and . characters. For Example

 [email protected]  ->  10203040+901301090+3015013


So, now we have numbers which make it easier to apply any calculations. Once we get the solution, we will make a Hashing Library to solve problems in Software Industry

• You can use some sort of hashing function, keeping in mind that we can't really enforce the upper limit on the buckets, only make some probabilistic argument about why we probably wont exceed the upper limits. A trivial example of such a hashing function might be to convert the email to hex, add the digits, then mod by some value. To avoid bias towards certain results (e.g. if just modding the email converted to hex without further digit manipulation, that might just have everything @gmail.com go to same bucket) more complicated hashing functions can be used. Commented Apr 23, 2020 at 12:02

If each bucket can hold $$1000$$ keys, then key $$1-1000$$ are in first bucket, keys $$1001-2000$$ are in second bucket and so on.
Then given a key $$K$$ it lies in the $$\lceil \frac{K}{1000}\rceil$$ bucket.
Similarly if each bucket can hold $$n$$ emails, then you can replace $$1000$$ with $$n$$.
• relative to their positions with sorting is a problem because Email addresses are not fixed and increasing. So, We give any Email address a unique key according to it sorting then It will have different Key when new Emails are added and sorted. So, we will lose the Key for this Email Address. P.S. I didn't down voted your answer. Commented Apr 23, 2020 at 12:02