ML0204 Same-Partition Probability

75 customers fall randomly into three equal-sized databases, all partitions equally likely. What is the probability that Bob and Ben end up in the same database? How does the answer change for k databases and m named customers?

Three-panel scenario card. Panel one shows a grid of 75 customer dots with one blue dot labeled Bob and one orange dot labeled Ben. Panel two shows three databases A, B and C, each holding exactly 25 customers. Panel three asks whether Bob and Ben land in the same database, with the probability marked as unknown, and notes the generalization to k databases and m named customers

The Problem: A service splits 75 customers into three databases of exactly 25, and every such partition is equally likely. Bob and Ben are two of those customers, and we need the chance they land in the same database, then its extension to k databases and m named people.

Answer

The probability is 24/74 = 12/37 \approx 0.324, not the tempting 1/3. Fix Bob’s database first. By symmetry Ben is then equally likely to occupy any of the 74 remaining seats, and 24 of those seats sit in Bob’s database. Because every partition is equally likely, Ben’s seat is a uniform draw without replacement, so the answer is favorable seats over open seats. For k databases of size s = n/k this becomes (s-1)/(n-1), slightly below 1/k because fixed sizes make placements negatively dependent.

(1) Fix Bob, Then Place Ben: Conditioning on Bob’s database costs nothing because the three databases play identical roles. Given Bob’s seat, every arrangement of the other 74 customers is equally likely, so Ben’s seat is uniform over 74 seats.
(2) Count Favorable Seats: Bob’s database has 25 seats and Bob holds one, leaving 24 favorable seats out of 74, which gives 24/74 = 12/37.
(3) Counting Cross-Check: The chance both land in database A is \binom{73}{23} / \binom{75}{25} = (25 \cdot 24)/(75 \cdot 74). Multiplying by the 3 databases recovers 12/37, so the combinatorial count and the seat argument agree.
(4) Why Not 1/3: 1/3 is correct only when each customer is hashed independently. With fixed sizes Bob uses up a seat in his own database, which lowers Ben’s chance by exactly (k-1)/(k(n-1)) = 1/111.
(5) General Rule: A pair shares one of k equal databases with probability (s-1)/(n-1). All m named customers share one with probability \prod_{j=1}^{m-1}(s-j)/(n-j), which hits zero once m > s.

Three dashed panels for databases A, B and C, each drawn as a five by five grid of 25 seats. In database A the top-left seat is filled in blue and labeled Bob, and the other 24 seats are tinted green as the seats that would put Ben in the same database. Databases B and C each show 25 white open seats. A caption below reads P of same equals 24 over 74 equals 12 over 37, about 0.324, just below the one third of independent hashing

Figure 1: Fixing Bob’s seat turns the question into a single uniform draw. Ben takes one of the 74 open seats, and the 24 green seats in database A are the favorable ones, so P = 24/74 \approx 0.324.

Mathematical Formulation:
s = n/k
P(\mathrm{same}) = \frac{s-1}{n-1}
P(\mathrm{same}) = k \, \frac{\binom{n-2}{s-2}}{\binom{n}{s}}
P = \frac{24}{74} = \frac{12}{37} \approx 0.324
P_m = \prod_{j=1}^{m-1} \frac{s-j}{n-j}
P_m^{\mathrm{ind}} = k^{1-m}
\frac{1}{k} - \frac{s-1}{n-1} = \frac{k-1}{k(n-1)}

Where:

  • s is the fixed size of each database, n the total number of customers, and k the number of databases, so the interview case has n = 75, k = 3, s = 25.
  • P(\mathrm{same}) is the probability that two named customers share a database. The binomial form counts the ways to fill one chosen database so that it contains both, divides by all ways to fill it, and multiplies by the k interchangeable databases; whether the databases are labeled or unlabeled does not change the ratio.
  • P_m is the probability that m named customers all share one database, and j \in \{1, \ldots, m-1\} indexes each additional customer placed after the first. It equals k\binom{s}{m}/\binom{n}{m} and is 0 for m > s.
  • P_m^{\mathrm{ind}} is the independent-hashing baseline, where every customer picks a database uniformly and independently of everyone else.
  • The last line is the exact gap to the naive answer: 2/222 = 1/111 \approx 0.009 for the interview case, shrinking like 1/n.

Worked Example:
Shrink the problem to n = 6 customers in k = 3 databases of s = 2. There are 15 ways to split 6 people into 3 unordered pairs, and Bob is paired with Ben in exactly 3 of them, so the probability is 3/15 = 1/5, matching (2-1)/(6-1). Independent hashing would claim 1/3, a large error at this size. Back at full size, linearity of expectation gives a second check. Each of the \binom{75}{2} = 2775 customer pairs shares a database with probability 12/37, so the expected number of same-database pairs is 2775 \times 12/37 = 900. That count is actually fixed at 3\binom{25}{2} = 900 in every partition, which is a third derivation of 900/2775 = 12/37.

Candidates report this as a Citadel 2024 question, and the trap is the independence assumption. Under hash sharding each customer is placed independently, database sizes fluctuate around 25 with a standard deviation near 4.1, and the pair probability is exactly 1/3. Under a uniform equal-size partition the sizes are pinned, so knowing Bob’s database slightly crowds Ben out of it. If the sizes are fixed but unequal, the big database pulls pairs together and the answer jumps well above 1/3.

PropertyEqual sizes 25 / 25 / 25Independent hashingFixed sizes 50 / 15 / 10
Pair formula(s – 1) / (n – 1)1 / kSum of s_i (s_i – 1), divided by n (n – 1)
Pair value at n = 7512/37, about 0.3241/3, about 0.3332,750/5,550, about 0.495
Three named customers together552/5,402, about 0.1021/9, about 0.111121,050/405,150, about 0.299
Database sizesExactly 25 eachRandom, mean 25, standard deviation about 4.1Exactly 50, 15 and 10
Dependence between customersNegative: Bob uses one seat in his own databaseNoneNegative, outweighed by the pull of the big database

Login to view more content
Log in to track your progress

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *