On this page
Ten students walk into a lab with ten benches and each picks a bench at random. On average there is exactly one student per bench, yet you should expect three or four benches to stand empty. That gap is the balls-into-bins problem, and four lines of algebra explain it.
What is the balls-into-bins occupancy problem?
The balls-into-bins problem places m balls one at a time into n bins, and the number of balls in a bin is called its load (Wikipedia: balls into bins problem). In the simplest version m = n, and every ball picks its bin uniformly at random, independently of the others.
The same article lists uses of the model and its two-choice variant: load balancing (users picking servers), hashing (keys landing in table slots) and routing packets in data centres. Two questions matter most: how many bins stay empty, and how full the fullest bin gets.
How many bins stay empty on average?
The cleanest route uses indicator variables, as in these University of Waterloo lecture notes on balls and bins. Let N_i be 1 if bin i ends up empty and 0 otherwise.
One ball misses bin i with probability 1 − 1/n.
The balls are thrown independently, so all n balls miss bin i with probability (1 − 1/n)ⁿ.
The number of empty bins is N_1 + N_2 + ... + N_n, so by linearity of expectation its mean is n(1 − 1/n)ⁿ.
Since (1 − 1/n)ⁿ approaches 1/e, the expected number of empty bins is about n/e.
When m = n, the expected fraction of empty bins is 1/e, about 0.368, while the expected load of every bin is exactly 1 (Waterloo lecture notes). Both are true: bins with two or three balls make up for the empty ones. New to indicator variables? See our guide to linearity of expectation with indicator variables.
Worked example: what happens with n = 10?
Each bin's load is binomial with 10 trials and p = 1/10. Multiply each probability by 10 bins:
Empty: 10 × 0.9¹⁰ ≈ 3.49 bins (compare 10/e ≈ 3.68).
Exactly one ball: 10 × 0.9⁹ ≈ 3.87 bins.
Exactly two: 10 × 45 × 0.01 × 0.9⁸ ≈ 1.94 bins.
Exactly three: 10 × 120 × 0.001 × 0.9⁷ ≈ 0.57 bins.
Four or more: the remaining ≈ 0.13 bins.
The five numbers add to 10, a quick exam check, and 3.49 is already within 0.2 of 10/e.
What about one ball in every bin? That is 10! of the 10¹⁰ equally likely throws, a probability of about 0.00036, or 1 in 2,756. For large n, n!/nⁿ ≈ √(2πn)·e⁻ⁿ, so a perfect spread becomes vanishingly rare; see Stirling's approximation for n!.
How full is the fullest bin?
The maximum grows slowly with n. With high probability, the fullest of n bins holds (1 + o(1)) ln n/ln ln n balls, as the abstract of Azar, Broder, Karlin and Upfal's "Balanced Allocations" (SIAM Journal on Computing, 1999) states. Raab and Steger's "Balls into Bins": a simple and tight analysis (1998) also covers the cases where m ≠ n.
Treat this as a guide to growth, not a calculator: the o(1) term is large even for big n. For a million bins, ln n/ln ln n ≈ 5.3, but Gonnet's sharper formula for the expected maximum, Γ⁻¹(n) − 3/2 (summarised on Wikipedia), gives about 9. Either way, the growth is slow.
What is the power of two choices?
Now let each ball pick two random bins and go into the less full one. According to Azar and colleagues, the fullest bin then holds only ln ln n/ln 2 + O(1) balls with high probability, which they describe as exponentially less than before. With d choices the bound becomes ln ln n/ln d + Θ(1) (Wikipedia), so going from one choice to two does most of the work. That is why a hash table can use two hash functions and store each key in the shorter list.
How to practise occupancy problems for JEE
Putting distinct balls into distinct boxes is a standard permutations and probability exercise. A routine:
Name the indicator: "bin i is empty" or "bin i has exactly k balls".
Find its probability for one bin.
Multiply by the number of bins (linearity).
Check with n = 2 or 3 by listing every outcome.
For exact counts, count directly: n distinct balls leave exactly one of n boxes empty in C(n, 2) × n! ways (pick the pair that shares, then arrange).
Try these on the permutations and combinations JEE Main practice questions. If linearity of expectation or the binomial distribution feels shaky, each has its own lesson in the Fermi Concept Library, and the Fermi Problem Library has worked problems with a step-by-step solver that explains the reasoning rather than printing an answer.



